I
illegal.prime
Hi all, I'm looking at trying to improve the performance of showing a
bunch of controls on a panel.
I have a class that extends Panel. In that class, I do the following:
this.SuspendLayout();
this.Hide();
//add controls to "this"
AddControls();
this.ResumeLayout();
this.Show();
I have placed timing code in the above and the invocation of the Show
method is extremely slow (relatively speaking to everything else). All
of the other operations (including my custom AddControls method) take
less than half a second. Meanwhile Show always takes anywhere from a
second and a half to two seconds.
I have to use the above ordering in order to ensure the Panel gets
scroll bars to display properly since each invocation to the above code
can result in a completely different set of controls (ranging from 1
control to 50 or more controls). Also, if I don't use Hide first, then
the insertion of the controls can end up taking over 2 seconds.
The only paths I can think of pursuing are either:
a) finding some other way to get the Panel to figure out how much it
needs to scroll (i.e. something like Invalidate), and/or
b) determining why the show takes so long on each of contained controls
Any suggestions on how I could pursue A or B or if there is an option
C? Each of the controls I add are custom controls.
Thanks,
Novice
PS Not that it matters (since .Net is .Net) - but I'm using C#
bunch of controls on a panel.
I have a class that extends Panel. In that class, I do the following:
this.SuspendLayout();
this.Hide();
//add controls to "this"
AddControls();
this.ResumeLayout();
this.Show();
I have placed timing code in the above and the invocation of the Show
method is extremely slow (relatively speaking to everything else). All
of the other operations (including my custom AddControls method) take
less than half a second. Meanwhile Show always takes anywhere from a
second and a half to two seconds.
I have to use the above ordering in order to ensure the Panel gets
scroll bars to display properly since each invocation to the above code
can result in a completely different set of controls (ranging from 1
control to 50 or more controls). Also, if I don't use Hide first, then
the insertion of the controls can end up taking over 2 seconds.
The only paths I can think of pursuing are either:
a) finding some other way to get the Panel to figure out how much it
needs to scroll (i.e. something like Invalidate), and/or
b) determining why the show takes so long on each of contained controls
Any suggestions on how I could pursue A or B or if there is an option
C? Each of the controls I add are custom controls.
Thanks,
Novice
PS Not that it matters (since .Net is .Net) - but I'm using C#