Solved

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

Posted on 2004-03-23
1
340 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on link 14 46
Automated testing suggestions? 2 45
How to prevent website from publishing with errors 9 44
Visual Studio 2013 and Eclipse Neon 6 33
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

808 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