using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace VisualComponentsLib { public partial class MyDropDownList: UserControl { public MyDropDownList() { InitializeComponent(); } public void LoadValues(List Values) { if (Values.Count == 0) { return; } dropDownList.Items.AddRange(Values.ToArray()); } public void Clear() { dropDownList.Items.Clear(); } public string SelectedValue { get { if (dropDownList.Items.Count == 0) { return ""; } if (dropDownList.SelectedItem == null) { return ""; } return dropDownList.SelectedItem.ToString(); } set { if (dropDownList.Items.Contains(value)) { dropDownList.SelectedItem = value; } } } private void comboBox_SelectedValueChanged(object sender, EventArgs e) { if (dropDownList.BackColor == Color.LightGreen) dropDownList.BackColor = Color.Tomato; else dropDownList.BackColor = Color.LightGreen; } } }