MAIN and EVENTS in a WINFORM

C

cgia

I am quite expert with asp.net and I am now using for the first time a
winform. I am not familiar with the concept of Main() together with
events (like: sub event_dealer(...) handles ...)
Is it possible to mix both in a winform application?
Also, what is the equivalent of page_load in a winform app? Is it the
Main()?
 
M

Matt Hawley

Generally in the Main method, you create a new instance of your main form (we call frmMain) and run that form.

So, our code looks like:

public void Main(string[] args) {
Application.Run(new frmMain())
}

Then - in your frmMain, you can either run routines in the constructor, or capture the Load event and run you're routines there.

Matt Hawley, MCAD .NET
http://www.eworldui.net

I am quite expert with asp.net and I am now using for the first time a
winform. I am not familiar with the concept of Main() together with
events (like: sub event_dealer(...) handles ...)
Is it possible to mix both in a winform application?
Also, what is the equivalent of page_load in a winform app? Is it the
Main()?
 
G

Guest

To answer the last part of original question-"Also, what is the equivalent of page_load in a winform app? Is it the
Main()?

The equivalent of a web Page in in WinForms is the Form. The natural equivalent of the Page_Load event would then be the Form_Load event. However, if you are worried about good OOP principles, always override the Base class methods instead of depending upon events..that way the integration remains tight. Hence, the best alternative to coding in the Form_Load event, is to override the Form's OnLoad method. It is the OnLoad method that in turn raises the public Load event. Read about overriding base class methods and the story becomes clearer..
 

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