Using DataBinding with a user control
-
I created a user control which contains a combobox for table lookups. It basically sets up a DataAdapter and DataSet and binds it to the combobox. For access to the SelectedValue from forms that will use the control I added:
public object selectedValue { get { return this.combo.SelectedValue; } set { this.combo.SelectedValue = value; } }
The problem that I am having is when I add the user control to form and use simple binding on the property selectedValue, the value isn't updated. It will update if I set it directly. See below. Works (from a new form)this.comboSelector.selectedValue = 100;
// The comboSelector will update with the corrisponding data. Not Working (from a new form)this.comboSelector.DataBindings.Add(new System.Windows.Binding("selectedValue", dataSet, "table.column"));
I also tried:this.comboSelector.DataBindings.Add("selectedValue", dataSet, "table.column"));
When the Currency Manager's postion is chaged these values are not updated. What am I missing? Thanks in advance. Brett Slaski