Solved

Need Help Speeding Load Time of Programmatically Created Controls in VB.NET PC Application

Posted on 2011-09-13
5
339 Views
Last Modified: 2012-05-12
Hello,

I am developing a VB PC application using Visual Studio 2008 and the .NET 3.5 Framework.

In debug mode, my code loads programmaticlly created controls very slowly, but this is OK.  The problem is that when I run in release mode, the system is no faster.

I'm wondering if there is some setting(s) I need to change for the release mode configuration (i.e., maybe release mode is accidentally configured like debug mode in one or more ways that need to be altered).

Any help would be most appreciated.

Thank you, Stu Engelman
0
Comment
Question by:stuengelman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 36528521
Can you show us some code of how you create the controls? Unless you are creating hundreds of thousands, speed should not be an issue, rather memory usage should.
0
 

Author Comment

by:stuengelman
ID: 36528667
Hi Nepaluz,

In most cases I am loading multiple instances of progammatically instantiated User Controls.  The User Controls contain the native controls, such as text boxes, checkboxes, and buttons.  The typical User Control has about ten native controls.  The render speed is very slow, even if only 5-6 User Controls need to be rendered on my form.

Sample instantiation code is:

Dim dmxrow As New MXrow ' 'MXrow is the name of the User Control here
dmxrow.Name = "mxrow" & CStr(ii) 'ii is a counter
Me.Controls.Add(dmxrow)
dmxrow.Left = 40
dmxrow.Top = toplevel 'toplevel is serially updated so the controls are rendered vertically

Stu
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 36529254
Is there code that could be optimized in the UserControl constructor, Load event or VisibleChanged?

You also try to suspend the layout while loading your controls. This might help a bit:
Me.SuspendLayout()
'Load your controls
Me.ResumeLayout()
Me.PerformLayout()

Open in new window

0
 

Author Comment

by:stuengelman
ID: 36529446
James - FANTASTIC!  It's 100 times faster.

Thanks so much, Stu
0
 

Author Closing Comment

by:stuengelman
ID: 36529452
Great job, solution worked perfectly.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question