简体   繁体   中英

LookupEdit devexpress combo box

I have a lookupedit combo box using dev express tools. I want to somehow loop through and grab each value in the combox box. So If i have 5 values, I want to be able to iterate over all and grab the value.

I tried to assign the bindingsource to a datatable but i got unable to cast object of type source to datatable.

 Dim dt As DataTable = CType(BindingSourceWell.DataSource, DataTable)

Is there another way to do this?

WinForms data sources should implement at least the IList interface. So, you can cast the LookUpEdit data source to IList to get a number of rows:

IList list = lookUpEdit1.Properties.DataSource as IList;
int count = list.Count;

So, you can use count as a parameter in your for loop to traverse through all rows.

Then, you can get a row cell value by using the RepositoryItemLookUpEdit.GetDataSourceValue method:

for (int i = 0; i < count; i++) {
    var value = lookUpEdit1.Properties.GetDataSourceValue('your field name', i);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM