using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace ViewComponents { public partial class List_with_choice : UserControl { public List_with_choice() { InitializeComponent(); } public event Action SelectedItemChange; public string? Element { get { if (checkedListBox1.SelectedItem != null) return checkedListBox1.SelectedItem.ToString(); else return string.Empty; } set { if (value != null && checkedListBox1.Items.Contains(value)) checkedListBox1.SelectedItem = value; } } public void Fill_List(string str) //метод заполнения списка { if (str == null) { return; } checkedListBox1.Items.Add(str); } public void Clean_List() //метод очистки списка { checkedListBox1.Items.Clear(); } private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e) { SelectedItemChange?.Invoke(checkedListBox1.SelectedItem.ToString()); } } }