Link to home
Start Free TrialLog in
Avatar of Richard
RichardFlag for United States of America

asked on

VB.NET comboBox databinding

I would like to set a combobox datasource to evaluate an enum such that the dropdown lists the Text Values and the Selected Index reflects the integer value. Found that worked ok... but the problem I have is I want the Selected Index bound to a datarow. So when the user picks another text value in the combobox the index is pushed to the datarow.

The code below works ok but the combobox pushes the Text value to the datarow. How to I code it such that the combo selectedindex is updated to the datarow rather than the text value.

   cmbPlane.DataBindings.Add("Text", drCurrent, "Plane")
    cmbPlane.DataSource = System.Enum.GetValues(GetType(EcCplPlanes))
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of Richard

ASKER

Codecruiser thank... the links help me understand databindings better.


My problem actually turned out to be that I was binding the selectedindex to a datarow with a value before binding the datasource

So the belows seems to work ok...

cmbPlane.DataSource = System.Enum.GetValues(GetType(EcCplPlanes))
cmbPlane.DataBindings.Add("Text", drCurrent, "Plane")