简体   繁体   English

LookupEdit devexpress组合框

[英]LookupEdit devexpress combo box

I have a lookupedit combo box using dev express tools. 我有一个使用dev express工具的lookupedit组合框。 I want to somehow loop through and grab each value in the combox box. 我想以某种方式遍历并获取combox框中的每个值。 So If i have 5 values, I want to be able to iterate over all and grab the value. 因此,如果我有5个值,我希望能够遍历所有值并获取值。

I tried to assign the bindingsource to a datatable but i got unable to cast object of type source to datatable. 我试图将bindingsource分配给数据表,但是无法将类型为source的对象转换为数据表。

 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. WinForms数据源应至少实现IList接口。 So, you can cast the LookUpEdit data source to IList to get a number of rows: 因此,您可以将LookUpEdit数据源转换为IList以获取许多行:

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. 因此,您可以在for循环中使用count作为参数来遍历所有行。

Then, you can get a row cell value by using the RepositoryItemLookUpEdit.GetDataSourceValue method: 然后,可以使用RepositoryItemLookUpEdit.GetDataSourceValue方法获取行单元格值:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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