PIbd-33_Sergunov_M.A._COP_4/Library/CustomComponents/ZhelovanovVisualComponents/BooksForm.cs

70 lines
1.2 KiB
C#
Raw Normal View History

2023-11-17 09:56:34 +04:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace KOP_Labs
{
public partial class BooksForm : UserControl
{
public BooksForm()
{
InitializeComponent();
}
public string? SelectedValue
{
get
{
if (listBoxComponent.SelectedItem == null)
{
return null;
}
return listBoxComponent.SelectedItem.ToString()!;
}
set
{
if (value != null && !listBoxComponent.Items.Contains(value))
{
return;
}
listBoxComponent.SelectedItem = value;
}
}
private event EventHandler? _selectChanged;
public event EventHandler SelectChanged
{
add { _selectChanged += value; }
remove { _selectChanged -= value; }
}
public void FillValues(string values)
{
if (values == null || values.Length == 0)
{
return;
}
listBoxComponent.Items.Add(values);
}
public void ClearList()
{
listBoxComponent.Items.Clear();
}
private void listBoxComponent_SelectedIndexChanged(object sender, EventArgs e)
{
_selectChanged?.Invoke(this, e);
}
}
}