Hi
I have a UltraComboBox [B] in my application, for which, datasource is assigned as per the value of other UltraComboBox [A].
Now if I change value of ComboBox [A], Datasource of ComboBox [B] is changed without error, but if I select some value from dropdown for ComboBox [B] and then change Value of ComboBox [A] application crashes.
The error I receive when assigning new datasource is:
Can not find Column "OldColumnName"
Thanks
Shivangi
Hi Shivangi,
If you change the DataSource on UltraCombo [B], then some of the properties of [B] are no longer valid. For example, the ValueMember and DisplayMember properties. These properties point to columns in the Combo and those columns might not exist in the new data source. So I recommend that you clear these properties (set the to null) before you change the DataSource and see if that helps.
Also, the Value property of the combo is probably not valid, either, since it refers to a value in the old DataSource, So it probably wouldn't hurt to set the Value to null, also.
Finally, when you are setting the DataSource on the combo, it's a good idea to use the SetDataBinding method, instead of the DataSource and DataMember properties.
Hi Mike,
Thanks you for the response,
It does solve the error if I set ValueMember, DisplayMember and Value property to NULL.
I earlier tried to reset combobox by setting Datasource as NULL and combobox.refresh, But it was still giving me error.
Shouldn't it refresh all properties if I use datasource as Null and refresh view?
shivangibhatt said:Shouldn't it refresh all properties if I use datasource as Null and refresh view?
No, the control cannot assume that when you set the DataSet to null (or anything else) that you want other properties to be affected. You could, for example, set the DataSource to null and then set it to another data source which has the same data structure it was using before. In such a case, you would probably want to use the same ValueMember and DisplayMember settings.
It's very rare that setting one property to anything changes the actual value of another property. Doing this is not necessarily obvious to the developer and is almost certain to cause confusion.
Having said all of that, the control probably shouldn't be blowing up when you set the DataSource to null, because it should be smart enough to know that the ValueMember and DisplayMember columns are not going to be there. So that seems like a bug we should look into.
What version of the controls are you using?