I have a CheckedListBox
bound to a DataTable
. Now I need to check some items programmatically, but I find that the SetItemChecked(...)
method only accepts the item index.
Is there a practical way to get an item by text/label, without knowing the item index?
(NOTE: I've got limited experience with WinForms...)
You may try to browse your Datatable. YOu can do a foreach on the DataTabke.Rows property or use SQL syntax as below:
Cheers,
You can implement your own
SetItemChecked(string item);
The checkListBox uses
object.ToString()
to show items in the list. You you can implement a method that search across all objects.ToString() to get an item index. Once you have the item index, you can callSetItemChecked(int, bool);
Hope it helps.