سؤال

I need to create about 720 buttons or labels in my application during run time. The problem here is when I start my app or make it (re-)visible, I can see that buttons being loaded.

How can I avoid from it or make it faster?

هل كانت مفيدة؟

المحلول

The best way is to use Control.SuspendLayout Method before you've started to fill your control with buttons and than Control.ResumeLayout after you finished

نصائح أخرى

You could try suspending the layout before loading the controls, and resuming it afterwards. This should speed the loading: SuspendLayout

Here's a link which might prove useful reading: (tips on improving wndows forms apps performance) -

Winforms performance

It's hardly possible that you need all that buttons at once.

If ou're designing UI, split it in tabs, where tab rapresent UX logical groups.

If you're not designing UI, using control is not a good option, choose something else to draw on the screen and it will be much faster.

There are some good tips here you can go through to speed up your application.

http://devcomponents.com/blog/?p=361

That said, I would really raise a question on why exactly you need to load 720 buttons. There's a very good chance that you will only be using say 5% of the available controls on your form. Find out a good way to reduce them.

If you like to "hide" the process of loading all the controls just use a splash screen so the user can see that the application is loading but cannot see all the actual components until the loading is done.

PS: Think about splitting those buttons in groups because im sure you dont need all of them at one place(maybe split in tabs? and load them when the tab is pressed?) Well just think about it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top