Solved

Form Initialize and Form Load

Posted on 2008-10-03
7
876 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
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…

762 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