Opening MDI Child form within a MDI Parent form

odyzeus

Member
Joined
Feb 28, 2005
Messages
6
Programming Experience
Beginner
All,

Am trying to open a MDI child form by clicking a node in a Treeview control docked on the left side of a MDI Parent form .

This is the code on node click ,

Dim NewMDIChild As New frmClientList
'Set the Parent Form of the Child window.
NewMDIChild.MdiParent = Me
'Display the new form.
NewMDIChild.Show()
'Dock the Child form in space between the treeview control and right edge of MDI Parent form
NewMDIChild.dock = dockstyle.fill

THE PROBLEM is the child form opens below the Treeview control and a part of it is hidden under it. Please lemme know the method to prevent this and open the child form in a maximized view in the remaining space in the MDI Parent form.

Hope to interact with y'all and learn and contribute to the group.

Regds,
Odyzeus


 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
I don't use MDI's a whole lot so there maybe a better way to do it, but what you could do is work out the fill area and then use the anchor (instead of dock).

TPM
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
when you hit this line, it might be using the treeview as the parent instead of the form (i dont know for sure cause i'm not familiar with treeview):
NewMDIChild.MdiParent = Me

try:
NewMDIChild.MdiParent = FormName
 

odyzeus

Member
Joined
Feb 28, 2005
Messages
6
Programming Experience
Beginner
1) Can we specify a distance from the left edge of the Parent form where the child mdi form can be anchored from.I am seeing only options to anchor left,right ,top or bottom which allow anchoring from the edges of the container rather than from a distance from the edge of the container.Also the Anchor property doesnot exist for a in this case a 'form' unlike a control that can be laced and anchored on a parent form. Could you be more clearer?

2) Tried
NewMDIChild.MdiParent = Me
Msgbox.show(Me.text)
'form'I get only the name of the parent form- form1 .Hence I think Me is taken for the parent form only.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
There is an anchor property if you do it in code, but that may not work as you say (never tried it). I have thought of another way though. dock right and set the width of the child form to me.width - treeview.width.

TPM
 

odyzeus

Member
Joined
Feb 28, 2005
Messages
6
Programming Experience
Beginner
Thanks, is a smart method to open it. Have got the child form to open as I want it to by adjusting its width, height , anchor and dock properties.

But still when I maximize the child form, it is hidden behind the treeview control partially. Have modified the child form's formborder style to disable maximize.

Am getting a feel of the anchor and dock properties now.

-Odyzeus
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
You could reset the childs width in your form's resize event.

TPM
 
Top Bottom