How to access the Main form in a Windows form app

C

Claire

Is there a way to get access to the main form, I mean the one instantiated
by
Application.Run( new frmMain())

If anyone knows, please let me know.

Claire
 
H

Herfried K. Wagner [MVP]

Hello,

Claire said:
Is there a way to get access to the main form, I mean the
one instantiated by
Application.Run( new frmMain())

If anyone knows, please let me know.

\\\
Public Class Main
Private Shared m_AppMainForm As MainForm

Public Shared ReadOnly Property AppMainForm() As MainForm
Get
Return m_AppMainForm
End Get
End Property

Public Shared Sub Main()
m_AppMainForm = New MainForm()
Application.Run(m_AppMainForm)
End Sub
End Class
///

The instance of the main form can be accessed by typing 'Main.AppMainForm'.
 
C

Claire

Thank you very much. Works perfectly!

Herfried K. Wagner said:
Hello,



\\\
Public Class Main
Private Shared m_AppMainForm As MainForm

Public Shared ReadOnly Property AppMainForm() As MainForm
Get
Return m_AppMainForm
End Get
End Property

Public Shared Sub Main()
m_AppMainForm = New MainForm()
Application.Run(m_AppMainForm)
End Sub
End Class
///

The instance of the main form can be accessed by typing 'Main.AppMainForm'.
 

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