namespace RodionovLibrary.VisualComponents { public partial class ComboBoxControl : UserControl { private event EventHandler? _valueChanged; public event EventHandler ValueChanged { add { _valueChanged += value; } remove { _valueChanged -= value; } } public string SelectedValue { get { return comboBox.SelectedItem != null ? comboBox.SelectedItem.ToString()! : ""; } set { if (comboBox.Items.Contains(value)) { comboBox.SelectedItem = value; } } } public ComboBoxControl() { InitializeComponent(); } public void AddItems(List items) { foreach (string item in items) { comboBox.Items.Add(item); } } public void Clear() { comboBox.Items.Clear(); } private void ComboBox_SelectedIndexChanged(object sender, EventArgs e) { _valueChanged?.Invoke(sender, e); } } }