Get item index from databound DevExpress CheckedListBoxControl

旧巷老猫 提交于 2019-12-01 21:33:41

If a list box control is bound to a data source, you can iterate throught all listbox items using the the GetItem() method and the ItemCount property:

for(int i = 0; i < checkedListBoxControl.ItemCount; i++) {
    object dataRow = checkedListBoxControl.GetItem(i);
}

To find the index of the specified item you can use the FindItem() method
searching by DisplayText:

string s = "searchString";
int index = checkedListBoxControl.FindItem(startIndex, true, delegate(ListBoxFindItemArgs e) {
   e.IsFound = s.Equals(e.DisplayText);
});

searching by ValueMember:

object value = 100;
int index = checkedListBoxControl.FindItem(startIndex, true, delegate(ListBoxFindItemArgs e) {
   e.IsFound = object.Equals(value, e.ItemValue);
});

Please also take a look at the "How to get checked rows of a data-bound CheckedListBoxControl" article.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!