How to access the Main form in a Windows form app

  • Thread starter Thread starter Claire
  • Start date Start date
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
 
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'.
 
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'.
 
Back
Top