obrienkev

Hi,

I have a ComboBox set to DropDownList to prevent users from typing in data.

The ComboBox is binded to a dataset.

I want the first option to display automatically on the ComboBox as "Select an Option"

How do I do this

Thanks.



Re: Visual C# Express Edition ComboBox + DropDownList

Cameron Kloot

set the comboBox's text to "Select an Option"






Re: Visual C# Express Edition ComboBox + DropDownList

obrienkev

The DropDownList setting doesn't allow this.





Re: Visual C# Express Edition ComboBox + DropDownList

anubisascends

Just use the standard DropDown, then handle the keypress event. Click on the control, the go tot he event properties and double click on the KeyPress event. In the code block, place the following:

Code Block
e.handled = true;

This will prevent the user from entering any text and still allow you to use the tet property.






Re: Visual C# Express Edition ComboBox + DropDownList

obrienkev

Thanks.

But still unable to get the ComboBox to display "Select an Option".

Where should I place this code

Code Block
myComboBox.Text = "Select an Option";

I tried placing it before the dataset is filled but the ComboBox doesn't display it.





Re: Visual C# Express Edition ComboBox + DropDownList

anubisascends

Don't set it in code, click on the control and set the text property (in the property pane) to "Select an Option".






Re: Visual C# Express Edition ComboBox + DropDownList

obrienkev

tried that but no difference.