gradual slow down

N

Nathan Franklin

Hey guys...

I have a question regarding performance of windows forms..

Is it normal behaviour for a windows form to gradually become slower and
slower as more stuff gets loaded?

I have a tab control on my form which when the user selects a tab i
dynamically load a selection of controls to go onto the tabpage.. I have
monitored this with the QueryPerformance API and the results show that as
more controls get loaded and place onto the form, it starts to slow down
dramatically, 3 times slower plus then the orginal time. Could I be doing
something wrong or is this the way windows forms works... I understand why
it could slow down, but i ened to know a way around it... (My process at one
stage was taking up to 30 seconds to generate content... I have since
revised my structure and got it down to approx 4-5 seconds... I still need
it faster... I would like almost instant....

My times now start out about 60 ms per each control group (being about 6
controls of labels textboxes and checkboxes and a selectlistbox) and then by
the end (about 6 groups) is upto about 300ms. these controls arnt "grouped"
as such but are just controls in a particular section of my form.

I am using vs2005.

The tab control has a panel as the main container which all the controls go
in. (this panel stays small until the end of the generating process, then a
resize the panel.) All my controls are added to thier container before i
move them around or resize them...(Is this the best approach?)

any help would be great

thanks
nathan
 
E

Eric Pearson

One tip would be to add them all to that panel, arrange them, then add the
panel to the tabcontrol. Also try calling SuspendLayout() while moving controls
around (and ResumeLayout() afterwards).

Moving lots of controls around after they've been added will be slower.
Better to create and position them before they've been "created" (which happens
when added to the form).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top