tags:

views:

191

answers:

1

I need to be able to add several hundred instances of a custom control (UserControl) to a panel at once. When I do this using Controls.AddRange(), it hangs for a very long time. Is there something I need to do that will decrease the amount of time this takes?

+1  A: 

Adding hundreds of instances of a control will be relatively slow no matter how you do it.

Are you currently calling myPanel.SuspendLayout() and myPanel.ResumeLayout()? That will speed things up a bit.

If you describe your scenario in more detail, there may be a way to solve the issue without having hundreds of control instances active at the same time.

Eric J.
I've already tried using Suspend/Resume layout, so I'm guessing the answer is simply "I'm doing it wrong". I'll describe my situation in another question.
Daniel Schaffer
Here's the new question: http://stackoverflow.com/questions/1482353/winforms-custom-xml-editor
Daniel Schaffer