Solved

Form Initialize and Form Load

Posted on 2008-10-03
7
877 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
[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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 47

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
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
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 60 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 65 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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