combo box starts off blank

B

Brian Henry

Is there a reason when you have items in the items collection of a combo box
when set to dropdownlist mode why it doesn't select the first item by
default? by default it shows up as a blank box, which is strange unless you
manually select one or programaticly set the index to zero. thanks
 
H

Herfried K. Wagner [MVP]

* "Brian Henry said:
Is there a reason when you have items in the items collection of a combo box
when set to dropdownlist mode why it doesn't select the first item by
default? by default it shows up as a blank box, which is strange unless you
manually select one or programaticly set the index to zero. thanks

A listbox doesn't get the first item selected automatically too, so why
should this be done automatically for a combobox?
 
B

Brian Henry

in foxpro and a lot of MFC apps I have developed always had the first item
selected by default, along with ASP apps I've created. It seems strange to
have nothign selected but after you select something that you can no longer
change it to have nothing selected after that.
 
C

Cor Ligthert

Hi Brian,

You can set it selected index to -1
This is when you want to use it as a combobox (combined dropdown and
textbox, this version is as far as I know not on ASP). You can set it using
dropdownstyle to dropdownlist the form you find in an ASP page.

I hope this helps?


Cor
 
H

Herfried K. Wagner [MVP]

* "Brian Henry said:
in foxpro and a lot of MFC apps I have developed always had the first item
selected by default, along with ASP apps I've created.

If this was the default behavior in .NET, I would consider it to be a
bug. Selection should be done by the user.
It seems strange to
have nothign selected but after you select something that you can no longer
change it to have nothing selected after that.

Set the control's 'SelectedIndex' property to -1, this will remove the
selection. For databound textboxes, you will have to do that twice
because of a bug.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top