form load/activated best practices

  • Thread starter Thread starter Rob Hughes
  • Start date Start date
R

Rob Hughes

I'm new to Pocket PC development and I'm converting an application
from eVB to .NET. Something I've noticed is that the author of this
application uses the Form's Activated event in ways that I am used to
using the Form's Load event (in desktop development). I'm curious if
it's typical in Pocket PC development to use the Activated event this
way?

Thanks!
 
Rob,

Generally you'll want to continue to use the Load event for initialization
code.
 
what is this this Load event ?
I always do everything in the constructor.
what should I do in the Load event handler ?
 
Hi All,

There is a FAQ entry with general rules on this:

4.2. When should I use the form constructor versus the Load function?
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx#4.2

The Load method is called right before the Form is shown for the first time
and can be created by double click on the Form in the Designer or adding the
following code:

private void InitializeComponent()
{
//
// MyForm
//
this.Load += new System.EventHandler(this.MyForm_Load);
}

private void MyForm_Load(object sender, System.EventArgs e)
{
}

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Lloyd:

Each form has a load event Form_Load but as Ginny mentioned, it's not the
place to put your code, you should continue using the constructor.
 
Lloyd,

As the FAQ article describes, most operations involving the GUI need to be
in the Load event.
 
The difference is that in the ctor the Form doesn't fully "exist", so you
shouldn't be calling any methods of the Form or anything it contains unless
it was specifically created in the ctor before your calling code.

-Chris
 
Back
Top