Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eliminate null entry in combobox

Is there any property to remove the first (and empty) item in a combobox with style DropDownList ? In other words, I would like to choose the default selected item for a combobox.

I know i can validate the selected item with code, but i want to avoid showing message boxes to the user.

like image 245
guanabara Avatar asked Jan 08 '13 10:01

guanabara


2 Answers

Set the comboBox.SelectedIndex property to 0 to set the selection to the first item in the combobox.

like image 117
Djentleman Avatar answered Oct 25 '22 04:10

Djentleman


You should set the Text or SelectedIndex or SelectedValue property. In this way the combobox updates the text that's is showing and removes the first empty item (that actually is not a real item).

like image 30
Tobia Zambon Avatar answered Oct 25 '22 06:10

Tobia Zambon