Link to home
Start Free TrialLog in
Avatar of Tom Knowlton
Tom KnowltonFlag for United States of America

asked on

VB .NET: Programmatically set ComboBox selection

Suppose I have a combobox control in VB .NET that is assigned to a DataSource:

'ae.fnReturnAEList.Tables(0) returns a DataSet object
ComboBoxAELookup.DataSource = ae.fnReturnAEList.Tables(0)

Then the end-user types something in the ComboBox that is not in the list.

Since the value typed in is not in the list, an error results.

What I would like to do is default to the first item in the ComboBox (whatever that might be).

Thanks,

Tom
Avatar of Tom Knowlton
Tom Knowlton
Flag of United States of America image

ASKER

>>What I would like to do is default to the first item in the ComboBox (whatever that might be).

This would happen when the Focus leaves the ComboBox.
ASKER CERTIFIED SOLUTION
Avatar of reaves
reaves

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am not sure if the business rules allow me to set the style to "DropDownList".  I'll check on that.

For now I went with you second suggestion.

I actually found this on my own while waiting for a resonse, but it will be nice to have this question captured for future reference.

Thanks,

Tom