views:

93

answers:

2

I'm building a control that comprises 15x15 = 225 buttons, and needs to be resizable. Because it's a grid, anchoring and docking won't work. I've tried both TableLayoutPanel as well as handling the resize event to manually place and size controls. In both cases, resizing is unacceptably slow. Suspend/Resume Layout in the resize function when I'm manually handling the layout doesn't help.

Is there something fundamental that I can change to speed things up, or is this just a limitation of the native controls? I understand I can build a custom control from scratch, handling the clicks and painting myself -- though I'd prefer to stick with the native controls if possible.

Edit

I know it's a lot of buttons. My question is a technical one; not one about UI design.

+5  A: 

WinForms doesn't handle displaying this many controls at the same time unfortunately.

If I were in your situation I would first consider if I could split up the form in several pages. In many cases that would be easier to understand for the user as well.

But in your case that doesn't seem to be an option. Are you making something like a minesweeper style game? There you have a grid of buttons that all are clickable. In such a situation I would suggest you go for a custom owner drawn control where you consolidate all the buttons in one control. Don't build a composite control that contains 225 buttons - that won't help at all :-)

A final option could be to switch to WPF. WPF uses hardware accelerated rendering so it may be faster, but with so many controls not even that may help.

Rune Grimstad
Gotcha. Can you point me to something beyond "just can't handle it" -- is there a blog post/performance explanation somewhere that can help me understand what's causing things to die? +1 for not trying to smart-alecky sidestep the technical question. I know it's a lot of buttons and I understand that. Custom control it is.
phillipwei
I'm speaking out of personal experience here :-) Much better than any blog post... hehe.
Rune Grimstad
No really. I have tried to do similar stuff and ended up with a completely unusable form. Performance is ok up to a certain point where it breaks down. Maybe you can get away with a 10x10 grid, maybe 12x12 or 8x8, but at a certain point it will become unusable.
Rune Grimstad
A: 

It's not for the faint-of-heart, but here's how I do that. I do this in C# with Winforms, and it works OK.

Mike Dunlavey