Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Setting MdiParent property on a form created by another non-Mdi form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Earl - 26 Jul 2006 08:09 GMT
How do I set a form's MdiParent property to the MdiParent when it is NOT
created by the MDIParent?

For example, frmMain creates frmA, frmA creates frmB .. how to make frmMain
the MdiParent of frmB?

private void btnAddNew_Click(object sender, EventArgs e)
{
frmB frmB = new frmB();
// this will not work
//frmEntry.MdiParent = frmMain;
frmEntry.Show();
this.Close();
}
Pritcham - 26 Jul 2006 11:35 GMT
Hi

If frmMain is your parent, and creates frmA then presumably you've set
frmA.MdiParent = me (from frmMain)? If you're then creating frmB from
frmA could you not do the following in frmA

frmB frmB = newfrmB()
frmB.MdiParent = frmMain

does that not work?  I know you've said it doesn't but the code you've
shown is setting the MdiParent property of another form (frmEntry)

Martin

> How do I set a form's MdiParent property to the MdiParent when it is NOT
> created by the MDIParent?
[quoted text clipped - 10 lines]
> this.Close();
> }
Earl - 26 Jul 2006 21:02 GMT
Yes, that should've been frmB instead of frmEntry in the code. But no, that
does not work, setting frmB.MdiParent to frmMain ... Joris had the answer,
need to set the MdiParent of frmB to the MdiParent property of THIS form:

// making this assignment from frmA
frmB.MdiParent = this.MdiParent;

> Hi
>
[quoted text clipped - 25 lines]
>> this.Close();
>> }
Joris Zwaenepoel - 26 Jul 2006 14:24 GMT
If frmA has frmMain as its MDIParent, then you could write

frmB.MDIParent = Me.MDIParent

of if frmA is not a MDI Child form, maybe it has frmMain as its owner form,
then you can use:

frmB.MDiParent = frmA.Owner

Hope this helps,

Joris

> How do I set a form's MdiParent property to the MdiParent when it is NOT
> created by the MDIParent?
[quoted text clipped - 10 lines]
> this.Close();
> }
Earl - 26 Jul 2006 21:03 GMT
Thanks Joris, that is the right idea:

// making the assignment from frmA (which was created by frmMain)
frmB.MdiParent = this.MdiParent;

> If frmA has frmMain as its MDIParent, then you could write
>
[quoted text clipped - 25 lines]
>> this.Close();
>> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.