Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I have a ComboBox with the following items in the item list:
{
   A
   B
   C
   DEF
   DE
}

Currently the SelectedIndex is 4.

But upon clicking upon the Dropdown, the SelectedIndex is changed to 3 ( the item in this case is DEF) while debugging. This is really unexpected as i haven't changed any value when DropDown is opened.
Help needed.
Posted
Updated 10-Feb-11 19:22pm
v2
Comments
shakil0304003 11-Feb-11 1:33am    
Not Clear!!!
shakil0304003 11-Feb-11 1:50am    
"But upon clicking upon the Dropdown, the SelectedIndex is changed". I did not get that change. Please, check your dropdown click event.
MCY 11-Feb-11 4:45am    
how do you get your index value on just clicking? by clicked event?
why don't you check the value using selectedindexchanged event?

1 solution

SelectedIndex starts from 0 (Looks like you are assuming it should start from 1)

Thus, if you say selectedIndex=3 then it implies it is DEF only.
 
Share this answer
 
Comments
Albin Abel 11-Feb-11 2:03am    
Yes that is right. I think the answer is given!!
bssiddesh 11-Feb-11 2:51am    
Hi,

Thanks for the reply. I also assume index starts from 0. But the issue here is if the ComboBox contains similar items (like DEF, DE in the list) on DropDown its SelectedIndex changes to 3 (DEF) for no reason. IF you could try out in a simple ComboBox sample, the issue will be aparent to you.
I am looking for answer on how i can prevent this happening.
Sergey Alexandrovich Kryukov 11-Feb-11 14:37pm    
Then post your code and point out what seems to be a problem!
Sergey Alexandrovich Kryukov 11-Feb-11 14:37pm    
I voted 5 before I noted it does not answer OP question; well doesn't matter...
--SA
Sandeep Mewara 11-Feb-11 14:40pm    
:) Thanks SA!

Based on what OP posted, looked like the issue was as I said. Later, based on OP's comment, it was hard to understand the behavior. What OP suggested was not happening with me. Surely some code/design issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900