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 / September 2003

Tip: Looking for answers? Try searching our database.

MdiParent Issue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dm_dal - 26 Sep 2003 23:26 GMT
All,
I have a c# windows application that I'm working on.  The main window
(frmMain) IsMdiContainer is set to true.  I have a second form (frm2) that
is instantiated as a MdiChild form.

frm2 is instantiated like thus:

 private void initChildForms()
 {
      Form myForm = new frm2();
      myForm.MdiParent = this;
      myForm.Show();
 }

My issue is that within frm2, when I try to set

this.Height = this.MdiParent.ClientSize.Height;

I get a null exception (MdiParent is null).  How else can I get the
MdiParents ClientSize.Height ?
Andrew \(Infragistics\) - 27 Sep 2003 01:14 GMT
You must be calling that too early. Try waiting for the ParentChanged event.

> All,
> I have a c# windows application that I'm working on.  The main window
[quoted text clipped - 16 lines]
> I get a null exception (MdiParent is null).  How else can I get the
> MdiParents ClientSize.Height ?
Chris Botha - 27 Sep 2003 04:33 GMT
Do you want the MDI child to fill the parent's client area? If so, then
after showing the child, thus after  childForm.Show(), set the WindowState
property of the child to Maximized.

> All,
> I have a c# windows application that I'm working on.  The main window
[quoted text clipped - 16 lines]
> I get a null exception (MdiParent is null).  How else can I get the
> MdiParents ClientSize.Height ?
Herfried K. Wagner [MVP] - 27 Sep 2003 11:47 GMT
"dm_dal" <dmy75252@yahoo.com> scripsit:
> I have a c# windows application that I'm working on.  The main window
> (frmMain) IsMdiContainer is set to true.  I have a second form (frm2) that
[quoted text clipped - 15 lines]
> I get a null exception (MdiParent is null).  How else can I get the
> MdiParents ClientSize.Height ?

Where are you calling the code that gets the client size?

Signature

Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet

dm_dal - 29 Sep 2003 14:07 GMT
It's being called in the frm2 constructor, right after the call to
InitializeComponent()

I'm placing two custom controls on frm2 (the first is a custom panel with a
lable and combobox, it's Dock property is set to DockStyle.Top, the second
is a third-party control who's height is determined by the containers
ClientSize.Height). The issue is when I initialize the form, The third party
control fills the form height and the custom panel is overlaid on top of the
third party control.  However, if I resize my form when it's running, the
third party control adjust it's size (as it should) and is no longer under
the panel control (this is correct behavior).

So, I figured if I could set frm2's height to samller than I want it
(design-time) then resize it during initization (run-time) then the that
would compensate for the incorrect sizing.

dmy
> "dm_dal" <dmy75252@yahoo.com> scripsit:
> > I have a c# windows application that I'm working on.  The main window
[quoted text clipped - 18 lines]
>
> Where are you calling the code that gets the client size?
Ying-Shen Yu[MSFT] - 30 Sep 2003 03:50 GMT
Hi dmy,
You may try putting this statement ,
this.Height = this.MdiParent.ClientSize.Height;
in your On_Activate event handler of your MDI child form.
If you still have problem, please let me know.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "dm_dal" <dmy75252@yahoo.com>
| References: <e7eyB1HhDHA.1280@TK2MSFTNGP12.phx.gbl>
<isnetsn3.fsf@m.gmx.at>
| Subject: Re: MdiParent Issue
| Date: Mon, 29 Sep 2003 08:07:32 -0500
[quoted text clipped - 8 lines]
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:53378
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
[quoted text clipped - 38 lines]
| >
| > Where are you calling the code that gets the client size?

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.