Re: Difference between Form1() and Form1_Load() ?
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Fri, 25 May 2007 10:46:57 -0700
On Fri, 25 May 2007 02:04:08 -0700, Miroslav Stampar <miroslav.stampar@xxxxxxxxx> wrote:
Form1() is constructor and Form1_Load() is an event called during the
load of Form1. Form1() is called first and shortly after that
Form1_Load() is called. Calls are made automatically. Proper way for
putting initialization statements would be to put them into
Form1_Load() [...]
Just to clarify, it depends on what sort of "initialization" statements you're talking about.
As I understand it, the constructor is executed before the all of the underlying Windows data has been initialized. The internal .NET stuff is all there, but it's not all hooked up to Windows yet. So, you should wait until the Load event to do anything that involves actually interacting with Windows.
But for any sort of internal data initialization, the constructor is a perfectly appropriate to do that. In fact, I'd argue that it's a more appropriate place to do that, because the constructor is all about *creating* the object, while the Load event is specifically for dealing with things that have to be done as the control (a Form in this case) is actually being displayed.
Pete
.
- References:
- Difference between Form1() and Form1_Load() ?
- From: Carla Simeoni
- Re: Difference between Form1() and Form1_Load() ?
- From: Miroslav Stampar
- Difference between Form1() and Form1_Load() ?
- Prev by Date: Re: Can't debug IIS service from client app
- Next by Date: Re: Importing a C#.NET dll into Delphi
- Previous by thread: Re: Difference between Form1() and Form1_Load() ?
- Next by thread: Show function
- Index(es):
Relevant Pages
|