Combobox selected index

  • Thread starter Thread starter faisalsns
  • Start date Start date
F

faisalsns

Hi,
I am facing a peculiar problem in setting the selected index 9 of a customised combo programitically. For rest of the index it gets set but for the index 9 i.e element no 10 in the datatable it doesnt.

ie if i set it combo.SelectedIndex = 4, the selectedindex gets selected to 4
but if i say combo.SelectedIndex = 9, the selectedindex is still 4(reverts back to the previous entry).

I have tried by adding data row by row instead of the regular DataSource.

Can i find some help...

Regards
Faisal.
 
-----Original Message-----
Hi,
I am facing a peculiar problem in setting the selected
index 9 of a customised combo programitically. For rest of
the index it gets set but for the index 9 i.e element no
10 in the datatable it doesnt.
ie if i set it combo.SelectedIndex = 4, the selectedindex gets selected to 4
but if i say combo.SelectedIndex = 9, the selectedindex
is still 4(reverts back to the previous entry).
I have tried by adding data row by row instead of the regular DataSource.

Can i find some help...

Regards
Faisal.
from .NET's Largest Community Website:
http://www.dotnetjunkies.com/newsgroups/

ComboBox indices are 0-based, so if you only have 8 items
in the list, item 9 won't exist. That might be one
reason. The other thing I noticed is that there is
ComboBox property called MaxDropDownItems. I'm not sure if
this affects how many items you can put in the list or if
it's just the number that show. But you should check that
out too. Maybe experiment with it and see what happens if
you change it to 10.
 
Faisal,
Your code works fine for me. Try to catch an exception, setting the
combobox's selectedindex property is not giving me any problems at all.
Could you post your code, and mabye where it's being called from?
Jared

faisalsns said:
Hi,
I am facing a peculiar problem in setting the selected index 9 of a
customised combo programitically. For rest of the index it gets set but for
the index 9 i.e element no 10 in the datatable it doesnt.
ie if i set it combo.SelectedIndex = 4, the selectedindex gets selected to 4
but if i say combo.SelectedIndex = 9, the selectedindex is still 4(reverts back to the previous entry).

I have tried by adding data row by row instead of the regular DataSource.

Can i find some help...

Regards
Faisal.
Community Website: http://www.dotnetjunkies.com/newsgroups/
 
Back
Top