Open childform in mdi parent from another childform..

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
ize_manAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ize_manAuthor Commented:
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
MortenSlotKristensenCommented:
Shouldn't you set the MdiParent? Like:

form.MdiParent = mdiForm.MdiParent;
0
MortenSlotKristensenCommented:
I mean: form.MdiParent = mdiForm;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

MortenSlotKristensenCommented:
Damn it.. Just the first thing I posted :p
0
ize_manAuthor Commented:
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
MortenSlotKristensenCommented:
Yes indeed! :) That should do it.
0
CodeCruiserCommented:
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
CodeCruiserCommented:
Sorry i had this window open for sometime and then pasted the comment and other solution was already posted. Please ignore.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.