Dear hackers, how to get access to the listBox elements, tobish my checkbox and button in it. Why I can't get the methods and properties of the Button and CheckBox classes if I request them through Items. 
help pliz
Dear hackers, how to get access to the listBox elements, tobish my checkbox and button in it. Why I can't get the methods and properties of the Button and CheckBox classes if I request them through Items. 
help pliz
ListBox.Items returns a collection of elements of type object. To access the properties of certain objects you need to bring the collection item to the desired type.
object item = listBox.Items[i]; if(item is CheckBox) CheckBox cbx = item as CheckBox; private List<CheckBox> checkingList() { List<CheckBox> checkingList = new List<CheckBox>(); for (int i = 0; i < listBoxKursants.Items.Count; i++) { if (listBoxKursants.Items[i] is CheckBox) { CheckBox c = (CheckBox)listBoxKursants.Items[i]; checkingList.Add(c); } } return checkingList; } I decided. In this way, we access the CheckBox as an array and access each check in the list.
Source: https://ru.stackoverflow.com/questions/667176/
All Articles