I have a combobox that I pre-populate with numerous possible choices. But I also want the option open for the user to manually enter text that is not one of the choices. So I leave the DropDownStyle set to DropDown so this is possible.
My question is, what is the most efficient (yet proper) way to write the code to return the value the user either selects, or manually enters?
Currently I am using the following code. But it seems a bit verbose for such a simple task. Is there a better (shorter) way to obtain the same result?
string Code1 = comboBox_Code1.GetItemText(comboBox_Code1.SelectedItem);
if (Code1.Length == 0) Code1 = comboBox_Code1.Text;