Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DevExpress ComboBoxEdit datasource

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?

like image 553
user1688313 Avatar asked May 18 '26 20:05

user1688313


1 Answers

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();
}
like image 180
DmitryG Avatar answered May 21 '26 14:05

DmitryG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!