Silly combo box question

  • Thread starter Thread starter Adam Honek
  • Start date Start date
A

Adam Honek

Hi,

I've looked over and over and in MSDN 2005 and just can't find what
is a really simple answer.

How do I select the first value in a combo box to be shown?
I tried the .selectedindex -1 but it doesn't work.

At the moment it populates fine but it just remains blank unless I
dropdown the list.

Thanks,
Adam
 
Adam Honek said:
I've looked over and over and in MSDN 2005 and just can't find what
is a really simple answer.

How do I select the first value in a combo box to be shown?
I tried the .selectedindex -1 but it doesn't work.

At the moment it populates fine but it just remains blank unless I
dropdown the list.

Set the 'SelectedIndex' property to 0. Setting it to -1 causes no item to
be selected, which is indicated by the blank combobox.
 
Adam,

The first is 0 as most things that are derived from classic VB.

If you want an empty box by not binded data than you can use -1.

I hope this helps,

Cor
 
Adam,
The first is 0 as most things that are derived from classic VB.

If you want an empty box by not binded data than you can use -1.

Unless you are talking Dotnet 1.x and currently have a value selected. In
that case, you need to set it to -1 twice (or sometimes 3 times). Actually,
I think the implementation in 2.0 sets the selectedindex to 0 then -1 if
you try to set it to -1 when it is currently > 0, which effectively means
that unselecting a value will cause a value to be selected temporarily and
then unselected. This to me is more silly than the original question which
has already been answered.

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
 
Back
Top