Zhelovanov_Dmitrii_COP/KOP_Labs/BooksForm.cs
2023-11-30 23:20:29 +04:00

70 lines
1.2 KiB
C#

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);
}
}
}