combobox problem - two selectedindex properties

  • Thread starter Thread starter Nikhil Patel
  • Start date Start date
N

Nikhil Patel

Hi all,
I am using the standard System.Windows.Forms.ComboBox controls on a form.
There are 5 or 6 comboboxes and their selection depends on each other. The
comboboxes behave strangely probably because there are two properties called
SelectedIndex and selectedIndex. Both usually have different values. Has
anyone experienced any problems using comboboxes?

Thanks.
 
Hi,

AFAIK there is one SelectedIndex which return the index of the item selected
and SelectedItem that return the item itself

How are the controls behaving?

Cheers,
 
Hi,
It is hard to explain all the problems. But for example, when I want to
clear the selection, I try to set the SelectedIndex property to -1. But it
stays at 0. I also tried to set it to -1 twice. But it does not change
to -1. In the locals window each combobox shows two properties -
SelectedIndex and selectedIndex and these property almost always have
different values. I just need to be able to clear the selection and fire the
SelectedIndexChanged event upon clearing the selection. Now I have managed
to successfully clearing the selection by seting null to SelectedItem
instead of seting SelectedIndex to -1. But when the DropDownStyle is
DropDownList, it throws an exception.

Thanks.
 
Hi,

Can you post some code?
I find very weird what you describe, You may see two SelectedIndex if you
use the watch windows, one may be the property, other may be the internal
variable, or maybe the inherited value. but anyway they all must have the
SAME value.


Cheers,
 
Back
Top