Solved

Get a reference to the start up form

Posted on 2010-08-12
4
371 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now