Solved

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

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# XML Get Values 4 54
Check only one toolstripmenu item 12 63
Can Selenium do Load Testing? 2 61
PowerShell:  foreach where object notmatch? 17 84
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

752 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