C# Winforms: Efficiently Displaying Many Controls

前端 未结 1 1642
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 09:39

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 TableLayoutPan

相关标签:
1条回答
  • 2021-02-19 10:04

    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.

    0 讨论(0)
提交回复
热议问题