Solved

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

Posted on 2004-03-23
1
339 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
ID: 10659595
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

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

Suggested Solutions

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

15 Experts available now in Live!

Get 1:1 Help Now