DataBinding BusinessObject to ComboBox

I have 2 Business Objects, say User and Type. User HAS a Type. I'm trying to bind the User class to Win Controls. I've DataBound a Combobox's items to a collection of all the Types available. I then databind the ComboBox's SelectedItem property to the User's Type property. When the form loads the Type is selected properly. However, if I change the selected Type in the ComboBox my User's Type property is not updated. Am I misunderstanding the correct behavior here or is something wrong

public Class User
{
public Type Type{...}
public string Name{...}
...
}

public Class Type
{
public string Name{...}
...
}

public void Main()
{
...
User u = new User("John");
u.Type = ListOfTypes["Admin"];
...
ComboBox1.DataSource = ListOfTypes;
ComboBox1.DisplayMember = "Name";
ComboBox1.DataBindings.Add("SelectedItem", u, "Type");
...
}


The way I understand DataBinding when I change the selected item in the combobox my User class's Type property should be set to the new item. What's wrong


Answer this question

DataBinding BusinessObject to ComboBox

  • DataBinding BusinessObject to ComboBox