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 Components { public partial class CustomComboBox : UserControl { public CustomComboBox() { InitializeComponent(); } public void ClearComboBox() { comboBox.Items.Clear(); comboBox.SelectedItem = null; comboBox.Text = string.Empty; } public string SelectedItem { get { return comboBox.SelectedItem?.ToString() ?? string.Empty; } set { comboBox.SelectedItem = value; } } public ComboBox.ObjectCollection ComboBoxItems { get { return comboBox.Items; } } private EventHandler _onValueChangedEvent; public event EventHandler ValueChangedEvent { add { _onValueChangedEvent += value; } remove { _onValueChangedEvent -= value; } } private void CustomComboBox_SelectedValueChanged(object sender, EventArgs e) { _onValueChangedEvent?.Invoke(sender, e); } } }