Reference Application MainForm or ApplicationContext
-
In a WinForms project, the Application.Run method can receive a Form parameter which becomes the main form of the application. According to the documentation, an ApplicationContext is automatically created. My question is, is it possible to get a reference to the MainForm of the application or the ApplicaitonContext that is automatically created? Thanks, Dan...
-
In a WinForms project, the Application.Run method can receive a Form parameter which becomes the main form of the application. According to the documentation, an ApplicationContext is automatically created. My question is, is it possible to get a reference to the MainForm of the application or the ApplicaitonContext that is automatically created? Thanks, Dan...
I'm not sure I understand exactly what you want to do, but the default Main() code looks like: [STAThread] static void Main() { Form1 form = new Form1(); Application.Run(form); } So the reference exists at that point. Obviously from within Form1, you have a reference with "this". The main questions would be - (1) where do you want to reference it? and (2) what specifically do you want to do with it?
-
I'm not sure I understand exactly what you want to do, but the default Main() code looks like: [STAThread] static void Main() { Form1 form = new Form1(); Application.Run(form); } So the reference exists at that point. Obviously from within Form1, you have a reference with "this". The main questions would be - (1) where do you want to reference it? and (2) what specifically do you want to do with it?