Hello,
I'm having some trouble with the DataBindings of the LookUpEdit control. I have some code that determines which set of enums should be available to choose from in a LookUpEdit based on various things. The basic approach I take is the following:
C#if (something) {
...
layoutControlItem1.Control.DataBindings.Clear();
layoutControlItem1.Control.DataBindings.Add(new Binding("EditValue", dataFeatures, "LongitudinalWeldType", true));
...
}
else {
...
layoutControlItem1.Control.DataBindings.Clear();
layoutControlItem1.Control.DataBindings.Add(new Binding("EditValue", dataFeatures, "LocationInWall", true));
...
}
however, even though the code flow executes correctly and the correct Binding is added to the emptied DataBindings, but the LookUpEdit control in the LayoutControlItem still shows the enum values associated with the LongitudinalWeldType enum. Is there anything else I need to do to make sure the new list of choices become available?
That was it. Thank you. I guess I don't understand the binding stuff too well. Can you briefly describe the difference between a DataSource and a DataBinding in this context?
Hi,
I've moved Nikita's comment to the answer section.
To bind the LookUpEdit's EditValue to a data source, call the LookUpEdit.DataBindings.Add method with corresponding parameters.
To bind the LookUpEdit's drop-down list to a data source, assign this data source to the LookUpEdit.Properties.DataSource property.
When customizing LookUpEdit, it's necessary to perform these data source bindings. It's also important to customize the LookUpEdit.Properties.ValueMember and LookUpEdit.Properties.DisplayMember properties correctly.
Please refer to the LookUpEdit Class article for more details.