Solved

Form Initialize and Form Load

Posted on 2008-10-03
7
870 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 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 69

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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 69

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unable  to create new object 9 41
Need to pass a connection through class/Method 1 40
Error in page 3 46
Runtime Error 2 29
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now