I am using DevExpress ComboBoxEdit and I need to bind list to its datasource. But as I can see there is no method to add datasource to control, so I added each item to control one by one like
foreach (var item in list) {
comboBoxEdit1.Properties.Items.Add(item);
}
It worked for but it is slow if there is lot of data.
Is there a way where I can bind list directly to control?
There is no way to bind the ComboBoxEdit directly to the datasource because the ComboBoxEdit is designed to be used when you need a simple predefined set of values. Use the LookUpEdit when you need to use a datasource.
You can use the the ComboBoxItemCollection.BeginUpdate and ComboBoxItemCollection.EndUpdate methods to prevent excessive updates while changing the item collection:
ComboBoxItemCollection itemsCollection = comboBoxEdit1.Properties.Items;
itemsCollection.BeginUpdate();
try {
foreach (var item in list)
itemsCollection.Add(item);
}
finally {
itemsCollection.EndUpdate();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With