Where are you stuck exactly?
If you know how to add items to
any collection programmatically, then you can easily apply that to any similar control.
Every control that behaves as a "list" (ComboBox, ListBox), usually has a property which implements the IList interface.
If a class implements IList, then it must implement its methods - like Add, Remove, Contains etc. (check ths MSDN documentation for a complete list:
IList interface members).
For example, ComboBox.Items is a property which implements the mentioned IList interface. This means that we can add items to that property, using the
Add method. Check MSDN for an example:
ComboBox.Items.
-
myComboBox.Items.Add("some item");
-
myComboBox.Items.Add("some other item");
If you can add a constant string to your combo box, then you can also add any property which is a string:
-
string itemToAdd = myTextBox.Text;
-
myComboBox.Items.Add(itemToAdd);