For example?
Main Topics
Browse All TopicsI have a VB.NET form with a large number of controls within a tablelayoutpanel. When I show the form, it takes quite a while to load and causes a great deal of flicker. Is there a way I can create the form, but not show it until all the controls are rendered? Right now I'm doing a simple:
Dim frm as myForm()
farm.show()
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you'd like a super-easy solution, do this:
1) Add a Timer to your form
2) Call the timer, "FormLoadTimer" and set the Interval to 100
3) Remove ALL code from your FormLoad event - move all the code into a new method called, "FormInitialize"
4) In the (now empty) FormLoad - turn on your timer, "FormLoadTimer.Enabled = True"
5) In the FormLoadTimer_Tick event, put the following code:
Sub FormLoadTimer_Tick(blah blah) Handles me.FormLoadTimer.Tick
FormLoadTimer.Enabled = False
FormInitialize()
End Sub
The form will load, setup all controls - resize the HORRIBLY SLOW TableLayoutPanel, get all of your painting done... Then it'll display the whole thing all at once, nice and clean when the Timer ticks...
Hope this helps.
-LK
I don't really understand why you haven't given the SuspendLayout a try. there are many ways of doing so, but the main thing is, whenever you change something, resize something or add something, use SuspendLayout. Here's a post that reports going from 20 seconds rendering to 2-3 seconds http://www.tek-tips.com/vi
Ok, so I tried. I had a hard time making the TableLayouPanel heavy enough to make it load slowly, but I managed by putting on a whole lot of different pictures with different scalings. To make it pretty obvious that it wasn't going smooth, I made the TableLayoutPanel resize with the form_resize event. It took quite a lot processing power and it had this shocky way of redrawing. It just "felt heavy" so to speak.
Then I added the SuspendLayout and ResumeLayout around the code. I made the Table originally Visible=False (in the designer) and showed it during load, and resized it to the right size. This helped a lot! All of a sudden everything ran much smoother and I can now easily resize the grid. I don't have timings, but the processor can now easily cope with it.
My suggestion is: try the same, it will save you a *lot* of time and the solution is remarkably simple to implement:
Abel's right ya know... his solution will definately make the 'load' go a ton faster but as for resizing your form with that TableLayoutPanel docked for resizing... you'll have to trap the form's resize to prevent the repeated refreshing of the TableLayoutPanel.
In that case, you might try suspending the layout while your form is resizing (Form.ResizeBegin) and then resume your layout when the resize is complete (Form.ResizeComplete)
Unfortunately this will result in a 'ghosting' look that is very unattractive as well. In my case(s) I just turn the TableLayoutPanel.Visible = False when the resize begins and back to True when the resize is complete.
thanks, lkalvin. Funny, I forgot that this 'difficult' question was just 50p, lol. That's probably why it wasn't split. I think with all the solutions around a split of many points would've been nice ;-)
Was a nice exercise to play a bit with that grid, I never use it normally, but the principles of design, rendering and paint events apply just the same ;-)
One final thought: if you really want that kind of professional looking resizing that some browsers or adobe can do, you can mimic that by grabbing an image of the whole area and resizing that during the resize event. Once it finishes, you remove that overlay image and you use the standard method explained above.
Business Accounts
Answer for Membership
by: AanvikPosted on 2009-05-13 at 12:10:08ID: 24378472
you can Load your form first before showing it.