Controlling Too Many listboxes ( C#)
Posted
by Ases
on Stack Overflow
See other posts from Stack Overflow
or by Ases
Published on 2010-04-17T11:41:42Z
Indexed on
2010/04/17
11:43 UTC
Read the original article
Hit count: 166
I have almost 200 listboxes. I'm changing their visibility according to my variables from database.
So I thought that, I prepared a arraylist. like this
ListBox[] lbs = this.Controls.OfType<ListBox>().ToArray();
And used like this.
for (int idx = 0; idx < Convert.ToInt32(ds.Tables[j].Rows[i][2])*12; idx++)
lbs[idx].Visible = true;
This codes are written to comboboxchange. Now everything is okay. But;
example;
first time I changed combobox
1-20 listboxes visible=true
I changed combobox again
not 1-20. 20,40 changing :S How can it be, can u tell me an alternative array list type, or another way?
© Stack Overflow or respective owner