Solved

Get a reference to the start up form

Posted on 2010-08-12
4
381 Views
Last Modified: 2013-11-26
I am currently creating and MDI application with vb.net in VS2010.  I would like be able to reference the main start up form in sub windows without having to pass the referencein the constructor or some other method.

Since the main form is also the StartUp Form i was hoping there might be a way to get a reference to that form from the application object.

Does anyone know if there is a way to do this?

Thanks in advance..
0
Comment
Question by:MRS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:NormanMaina
ID: 33423762
IN VB 2008

FrmChild.MdiParent=me 'thats if you are referncing if from a menu's click event.
FrmChild.show

or

Woeks in VB 2005

Dim frm as new frmChild
frm.MdiParent=me
frm.show
0
 

Author Comment

by:MRS
ID: 33423838
i was looking for something a little more global then that.  Through the course of the application i may need to reference that main form (start up form) from windows that aren't neccessarily child windows.

For instance if i open a dialog window.  For the time being i wrote this, i was hoping for a more elegant solution.
   Public Function GetMainForm() As frmMain
        Try
            For Each frm As Form In My.Application.OpenForms
                If frm.GetType Is frmMain.GetType Then
                    Return frm
                End If
            Next
        Catch ex As Exception
            Throw
        End Try
    End Function

Open in new window

0
 
LVL 12

Accepted Solution

by:
NormanMaina earned 500 total points
ID: 33423897
in vb 2008 all you need to do is call the form dicrectly from any other form.

ie frmmain.text="Success"
0
 

Author Closing Comment

by:MRS
ID: 33423908
I never knew that... Well that was easy... :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question