Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Form Initialize and Form Load

Posted on 2008-10-03
7
Medium Priority
?
881 Views
Last Modified: 2013-11-26
What is the difference between Form Initialize and Form Load? I am ofter confused on which functions to call in Form Initialize and which on Load.
0
Comment
Question by:rpkhare
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22631808
There is no Form.Initialize() event in .Net 2005. For calling routines when the form first opens, use the Form.Load() event.

Wayne
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22632367
Initialize is very early in the call chain. You normally cannot access controls from it.
0
 
LVL 15

Expert Comment

by:angus_young_acdc
ID: 22632649
Your form initialise would be one of the first things, so I tend to declare any simple stuff there which is required whilst the form is loading.  For the Form_Load I generally use that to set things such as whether a control is visible yet etc.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 8

Author Comment

by:rpkhare
ID: 22670237
emoreau,

Previously I was filling my DataGridView on Form Load. Later I decided to fill in From Initialize followed by Application.DoEvents(). This has considerably increased the performance. Why?
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 180 total points
ID: 22670266
I can't say. I would have to try/trace your code. Maybe you can play with suspendlayout/resumelayout
0
 
LVL 8

Author Comment

by:rpkhare
ID: 22675926
Can you please explain: Suspend Layout and Resume Layout.
0
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 195 total points
ID: 22676552
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.suspendlayout.aspx

The SuspendLayout and ResumeLayout are methods used in order to prevent conflict when events pertaining to placing and moving controls  and setting their attributes are thrown.

You would for instance perhaps  like to add controls onto a panel or a window programatically .. what you must do is suspend the control you are adding other controls to and after you are done adding ,you then can resume your layout by calling the ResumeLayout method.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

916 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