Solved

How do I set MDIChild form parent to something other than "me"

Posted on 2004-03-23
1
338 Views
Last Modified: 2010-04-14
I have a MDI .NET application.  There is a main form (frmMain) which opens a second form (frmOpen) as a dialog (i.e. Modal).  The frmOpen form will be used by the user to enter selection criteria and retrieve a list of database records.  They then select one record and click Open.  The frmOpen then opens a 3rd form (frmMaintain) and needs to set the MDIParent of that form to frmMain, and set a few options on the form.

So ... the question is ... how do you refer to a form that is already open?  I know I can declare a new form object, open it, and set the parent = me, but how can I set the parent = another form?

Here's the code I have:
<code>
      Dim NewMDIChild As New frmMaintainSession
      NewMDIChild.MdiParent = frmMain

      NewMDIChild.TextBox1.text = "Hello World"
      NewMDIChild.Show()

      Me.Close()
</code>
0
Comment
Question by:wmcmorri
1 Comment
 
LVL 15

Accepted Solution

by:
SRigney earned 20 total points
Comment Utility
Well there's 2 things here.  
1. The Main Form should actually be the one that opens the child form.  The dialog should only be used to locate which child to open.

The proof of this is that if you use a Commong Dialog to open a file it doesn't actually open the file, but locates it and allows you to use the properties that it has set to open the file in your code.

2. The code that you have should work, except that in .Net all forms are not available globally like they were in VB6.  Thus you need to tell frmOpen who frmMain is.  My guess is that since you are opening it as a Modal window you can use the parent property so this may work.

      NewMDIChild.MdiParent = Me.Parent


If not then you will need to create a property in frmOpen that is a pointer to the main form, then your code would work if you used the pointer variable in place of frmMain
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

10 Experts available now in Live!

Get 1:1 Help Now