Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Accessing the Main Application Window
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00875619
Message ID:
00875635
Vues:
17
This message has been marked as a message which has helped to the initial question of the thread.
>In the Developer's Guide, is says you can access the main application window by means of the static class and property App.Mainform. If you add properties to the MainForm, how do you access them from another form?

The quick answer to your question is that you can add Method/Properties to MainForm, but they have to be static methods or props. That carries with it the limitations (and power) of Static types in .Net

You can do something else in this case though, which will let you get to the instance variables and other non-static things through a static reference that is accessible everywhere in your winforms project:

1) Add a static variable to your MainForm of type MainForm.
public static MainForm oInstanceRef;
2) In the Load event of Mainform, set that static variable to the instance of MainForm:
MainForm.oInstanceRef = this;
Now, from anywhere in your project, you should be able to get to the running instance of MainForm, including any custom stuff you’ve added to it. There might already be something in MM.Net that handles this too...

-Nate
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform