59 lines
1.3 KiB
C#
59 lines
1.3 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 Library15Gerimovich
|
|
{
|
|
public partial class DefaultList : UserControl
|
|
{
|
|
public event EventHandler? SelectedValueChanged;
|
|
|
|
public string SelectedValue
|
|
{
|
|
get
|
|
{
|
|
return checkedListBox1.SelectedItem?.ToString() ?? string.Empty;
|
|
}
|
|
set
|
|
{
|
|
int index = checkedListBox1.Items.IndexOf(value);
|
|
if (index >= 0)
|
|
{
|
|
checkedListBox1.SelectedIndex = index;
|
|
}
|
|
else
|
|
{
|
|
checkedListBox1.ClearSelected();
|
|
}
|
|
}
|
|
}
|
|
|
|
public DefaultList()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void AddItemToList(string item)
|
|
{
|
|
ListBox.Items.Add(item);
|
|
}
|
|
|
|
private void SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
SelectedValueChanged?.Invoke(this, e);
|
|
}
|
|
|
|
public void ClearComboBox()
|
|
{
|
|
checkedListBox1.Items.Clear();
|
|
}
|
|
|
|
}
|
|
}
|