form load/activated best practices

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!
 
G

Ginny Caughey [MVP]

Rob,

Generally you'll want to continue to use the Load event for initialization
code.
 
L

Lloyd Dupont

what is this this Load event ?
I always do everything in the constructor.
what should I do in the Load event handler ?
 
G

Geoff Schwab [MSFT]

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.
 
W

William Ryan eMVP

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.
 
G

Ginny Caughey [MVP]

Lloyd,

As the FAQ article describes, most operations involving the GUI need to be
in the Load event.
 
L

Lloyd Dupont

mmhh... well, ok thank you ...

Ginny Caughey said:
Lloyd,

As the FAQ article describes, most operations involving the GUI need to be
in the Load event.
 
C

Chris Tacke, eMVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top