Hi all,
i need a 26 rows by 8 colums check boxes table.
i get the number of rows from a data base so i prefere to create the check boxes at run time.

the thing is it takes something like 10 seconds on my powerful computer to draw them all.
is there a better way to do it ?
the code :

while (row_num2<26)
for (int chk_cntr = 0; chk_cntr < 8; chk_cntr++)
     chkBox2[chk_cntr + 8 * row_num2] = new CheckBox();
     chkBox2[chk_cntr + 8 * row_num2].Name = "2_" + (chk_cntr + 8 * row_num2).ToString();
     tableLayout2.Controls.Add(chkBox2[chk_cntr + 8 * row_num2], chk_cntr + 2, row_num2 + 1);

Drawing 208 check boxes with GDI will be slow, even on fast machines. The UI operates on a single thread (and hence only a single core even on multi-core machines).

Is there any particular reason you need 208 check boxes? I think there's a design problem here. What's is it you're trying to achieve?

thanks for the reply,

i'm building a GUI for controling a block memory in a chip.
this block has 26 8bits addresses, in which the user should configure.
after acquiring the data I parse each 8 bits to a deciman value (0-255) then send it all using the usb driver to the chip.

is there a better way to do it ?


Then I would simply ask for a decimal value to begin with. That would reduce your control size to 26 text boxes.

Alternatively, request it in Binary representation and parse that into a decimal. It's pretty much this in reverse.

Another alternative is to have a drop down list/treeview/similar of addresses and 8 check boxes. Select the address you wish to set, then enable the checkboxes. Disable them after the data for that address has been sent/saved. This way you can get and set the values on the same 8 check boxes.

If the level of your user is up to it you could use also use Hexadecimal input.
It is often easier to conceptualise the bit paterns in Hex.

thank you again,

i've had those thoughts while designing, but i think the users whould get confused typing 8 bits in textbox (or maybe i'm underestimating them...)

the solution of a drop down is non practical because many of the adresses are corelated and the user has to see them all.

is it possible to put the 26*8 checkboxes on two tabpages and have two threds draw them in paralel ?

anyway thanks for the advices, if you come up with another solution i would love to hear.


thanks a lot for all the help. i went for the textbox solution. much more elegant this way !