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 ComponentLibrary1 { public partial class CheckList : UserControl { private event EventHandler? _сhangeEvent; public event EventHandler ChangeEvent { add { _сhangeEvent += value; } remove { _сhangeEvent -= value; } } public string SelectedItem { get { return checkedListBox.SelectedItem?.ToString() ?? string.Empty; } set { checkedListBox.SelectedIndex = checkedListBox.Items.IndexOf(value); } } public CheckList() { InitializeComponent(); } public void Input(string input) { if (string.IsNullOrEmpty(input)) throw new ArgumentNullException("input"); checkedListBox.Items.Add(input); } public void Clear() { checkedListBox.Items.Clear(); } private void checkedListBox_SelectedIndexChanged(object sender, EventArgs e) { _сhangeEvent?.Invoke(this, e); } } }