Laying out controls: suggestions for improving performance?

  • Thread starter Thread starter Frnak McKenney
  • Start date Start date
F

Frnak McKenney

Part of my current project involves laying out an event calendar.
At the customer's request, this takes the form of a scrolling panel
with three columns: a month and day, and two descriptive columns
which I've implemented as a Label and two LinkLabels.

Since other parts of the application can alter these events, I
rebuild it each time it is displayed. I'm now up to about forty
rows of text and the time to Clear() it and (re-)create it is
noticeable on an AMD 2600. The list is likely to grow, although
probably not more than doubling in size.

I tried bracketing the panel rebuild with SuspendLayout() and
ResumeLayout(false), but it still takes approaching a second to
switch between another Form and this one.

Is there some noticeably faster way to lay out the (40-odd)*3
controls on the panel and have it drawn? Would I be better off (he
says, the idea just occurring to him now at 2330) re-using the
controls with different Text values rather than using Clear() and
recreating them?

Any suggestions will be welcomed at this point (well, perhaps
any suggestion _other_ than "Recode the entire application in
MACRO-less Assembler". Or COBOL).

I don't suppose there's some wonderful 'web site out there in
'Net-land just chock full of suggestions for improving the
performance of VS.NET2003 applications? <grin>

Ah, well. Thanks for listening...


Frank McKenney, McKenney Associates
Richmond, Virginia / (804) 320-4887
Munged E-mail: frank uscore mckenney ayut minds pring dawt cahm (y'all)
--
"It is not enough that the rights of man be written in the books
of philosophers and inscribed in the hearts of virtuous men; the
weak and ignorant must be able to read them in the example of a
great nation. America has given us that example."
-- Condorcet, French Philosopher and Politician
--
 
Hey Frank,
Definitly dont delete all the controls on the form and recreate them each
time you paint. that will really slow down the app. Just go at it like any
other compound control. use what you already have...and if you need to
create a few new controls then do so. but dont start from a clean slate each
time.

The only time I'd sugest that approach if it was totally an owner drawn
control.
 
johnconwell,

Thanks for taking the time to reply. I'm now up to something like
120 lines (120*3 controls) and the Clear() and re-Add() is
approaching two seconds. Also, I seem to be triggering some sort of
bug in VSdotNET - sometimes, after three or four "refreshes" of this
particular panel my app goes into a loop (not unreasonable). When I
kill it with Task Manager, the looping gets "transferred" to
'devenv.exe' (which I assume is VSdotNET) and sometimes can be
killed and sometimes requires a reboot to completely clear (very
unreasonable).

Definitly dont delete all the controls on the form and recreate them
each time you paint. that will really slow down the app. Just go
at it like any other compound control. use what you already
have...and if you need to create a few new controls then do so. but
dont start from a clean slate each time.

Sounds like good advice. I'm also wondering whether the Clear() was
properly disposing of the discarded controls or whether I should
have been getting rid of each individually.
The only time I'd sugest that approach if it was totally an owner
drawn control.

I really started getting hit by app/environment lockups last
weekend, and my copy of Chris Sells' "Windows Forms Programming in
C#" arrived about the same time. As a result I'm trying to
reorganize (can I call it "refactoring"? <grin>) my code to use a
DataGrid instead, so I'll be posting another query shortly asking
about the DataGridXXXColumn text alignment problems I'm running
into.

Nothing is ever easy, is it? I don't want _much_... just a
complete set of responsive controls with overhead approaching zero
that do exactly what I want them to do, when I want them to do it,
and nothing more. <grin>

Anyway, thanks again for the reply.


Frank McKenney, McKenney Associates
Richmond, Virginia / (804) 320-4887
Munged E-mail: frank uscore mckenney ayut minds pring dawt cahm (y'all)
--
Knowledge does not necessarily imply judgment. All truly
critical, as against technical, argument is either intuitive or
hypothetical or partial. This cannot be compensated for by a
study of the raw material, however exhaustive.
-- Robert Conquest, "The Dragons of Expectation"
--
 
Back
Top