C# Combobox and TabControl woes
Posted
by
Jake
on Stack Overflow
See other posts from Stack Overflow
or by Jake
Published on 2010-12-27T06:55:34Z
Indexed on
2010/12/27
9:54 UTC
Read the original article
Hit count: 267
tabpage
enter code here
I have a TabControl on a Form and in the TabPages there are ComboBoxes.
When the form OnLoad, I populate the ListItems in the ComboBoxes and the attempt to set default values to string.Empty.
However, the ComboBox.SelectedText = string.Empty only works for the first TabPage. The other ComboBoxes ignore the command and take the default value as the first item in the list. Why is this so? How can I overcome it?
The ComboBoxes are all set up by this function
public static void PrepareComboBox(ComboBox combobox, FieldValueList list)
{
combobox.DropDownStyle = ComboBoxStyle.DropDown;
combobox.AutoCompleteSource = AutoCompleteSource.ListItems;
combobox.AutoCompleteMode = AutoCompleteMode.Suggest;
combobox.DataSource = list.DataSource;
combobox.DisplayMember = list.DisplayMember;
combobox.ValueMember = list.ValueMember;
combobox.Text = string.Empty;
combobox.SelectedText = string.Empty;
}
© Stack Overflow or respective owner