?
Solved

Open childform in mdi parent from another childform..

Posted on 2008-11-06
8
Medium Priority
?
503 Views
Last Modified: 2012-05-05
Hi

I have a MDI paren form witch works fine... now I want to open a existing childform when i double click on a row in a DataGrid... Followin code opens the form, but outside the "parent"

 EditUser form = new EditUser(username);
form.Show();

and when i run this code the form does not appear at all....

Form mdiForm = this.ParentForm;

if(mdiForm.ActiveMdiChild != null)
{
if(username != null)
{
EditUser form = new EditUser(username);
form.TopLevel = false;
form.Parent = mdiForm;
form.Show();
}
}

I have a Telerik DockingManager on my MDI Parent witch displays the child forms in a different "Tab"...

Any idea?

Regards
0
Comment
Question by:ize_man
  • 4
  • 2
  • 2
8 Comments
 

Author Comment

by:ize_man
ID: 22898604
Forgot a small issue...
When i run debug mode the EditUser form i am trying to open hat IsMdiChid propery set to null....maybe that's the proplem. If so, how do I fix that?
0
 
LVL 2

Expert Comment

by:MortenSlotKristensen
ID: 22898773
Shouldn't you set the MdiParent? Like:

form.MdiParent = mdiForm.MdiParent;
0
 
LVL 2

Accepted Solution

by:
MortenSlotKristensen earned 1500 total points
ID: 22898807
I mean: form.MdiParent = mdiForm;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:MortenSlotKristensen
ID: 22898816
Damn it.. Just the first thing I posted :p
0
 

Author Comment

by:ize_man
ID: 22898869
hahah....that's just the case..

I just figured it out. You soulution was the right track but i had to "set" the MdiParent before calling the EditUser form.. followin code snippet does the trick.

Form mdiForm = this.ParentForm; //THIS IS NECESSARY
            if (mdiForm.ActiveMdiChild != null)
            {
                if (username != null)
                {
                    EditUser form = new EditUser(username);
                    form.MdiParent = mdiForm;
                    form.Show();
                }
            }
0
 
LVL 2

Expert Comment

by:MortenSlotKristensen
ID: 22898886
Yes indeed! :) That should do it.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22899008
You are not setting the MDIParent property so IsMDIChild property is null or false. You can use a public variable in EditUser form and set that to the parent form like this.

Public Class EditUser
          Inherits Form
public fmain as frmMain
...
dim f as new frmNewUser
f.MDIParent=fmain
f.Show
End Class

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 22899023
Sorry i had this window open for sometime and then pasted the comment and other solution was already posted. Please ignore.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

809 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