Control Array
-
Hi, I have a control array and have tested the control type to find a listview. I want to assign the control to a listview with something like below. System.Windows.Forms.ListView olistview = new ListView(); olistview = g_control_array[i]; C# does not like this and i get a cannot convert control to listview. Is there a way to achieve this as I can't find anything to help do this. The only othe way I can think of is to establish an array of listviews as well but i would prefer not to do this unless I have to. Thanks for any help. Stephen
-
Hi, I have a control array and have tested the control type to find a listview. I want to assign the control to a listview with something like below. System.Windows.Forms.ListView olistview = new ListView(); olistview = g_control_array[i]; C# does not like this and i get a cannot convert control to listview. Is there a way to achieve this as I can't find anything to help do this. The only othe way I can think of is to establish an array of listviews as well but i would prefer not to do this unless I have to. Thanks for any help. Stephen
You want to read a ListView out of the control array? Then you won't have to create a new one. The control array can contain any control, so you have to tell the compiler "I'm sure this item is a ListView": ListView olistview; olistview = (ListView)g_control_array[i];
-
You want to read a ListView out of the control array? Then you won't have to create a new one. The control array can contain any control, so you have to tell the compiler "I'm sure this item is a ListView": ListView olistview; olistview = (ListView)g_control_array[i];
Worked. Thanks. Too easy! Stephen