J
John Kraft
I am using a combobox in an application that is databound to
a datatable. The visible item in the combobox corresponds
to the job classification of an employee: accountant,
manager, etc.
Due to data entry errors, some employees do not have a
classification in the db. For these entries, I want the
combobox to display nothing. I accomplish this by setting
the combobox's selectedIndex property to -1. In doing so,
I encountered some interesting behavior.
setting SelectedIndex = -1 always sets the SelectedIndex to
0, UNLESS the SelectedIndex is already 0 or -1.
(example)
myComboBox.SelectedIndex = -1;
produces a SelectedIndex of 0.
myComboBox.SelectedIndex = -1;
myComboBox.SelectedIndex = -1;
or
myComboBox.SelectedIndex = -0;
myComboBox.SelectedIndex = -1;
produces a SelectedIndex of -1.
Is this the expected behavior of this control, or is this a
bug in the control?
I'm using VS.NET 2003 and .NET 1.1.
Thank you,
John Kraft
a datatable. The visible item in the combobox corresponds
to the job classification of an employee: accountant,
manager, etc.
Due to data entry errors, some employees do not have a
classification in the db. For these entries, I want the
combobox to display nothing. I accomplish this by setting
the combobox's selectedIndex property to -1. In doing so,
I encountered some interesting behavior.
setting SelectedIndex = -1 always sets the SelectedIndex to
0, UNLESS the SelectedIndex is already 0 or -1.
(example)
myComboBox.SelectedIndex = -1;
produces a SelectedIndex of 0.
myComboBox.SelectedIndex = -1;
myComboBox.SelectedIndex = -1;
or
myComboBox.SelectedIndex = -0;
myComboBox.SelectedIndex = -1;
produces a SelectedIndex of -1.
Is this the expected behavior of this control, or is this a
bug in the control?
I'm using VS.NET 2003 and .NET 1.1.
Thank you,
John Kraft