Solved

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

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

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

630 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