Mdi Child Size

D

Daniel

Why does VB ignore my width and height settings of my Mdi child form.

I have a parent form. On the left is a treeview with a splitter. I
want to open a child form up in the remaining space and size the
controls on it according to the width of the main form. So:

On the parent form:

Dim myFrm2 as Frm2

Frm2.MdiParent = Me
Frm2.Show()


On the child Form:
Private Sub Frm2_SizeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.SizeChanged


Listbox1.Width = Me.Width - 25
Listbox1.Height = Me.Height - 25

End Sub


What this does is resize the control to the size of the parent form not
the child form. Any ideas????
 
D

Daniel

Daniel said:
Why does VB ignore my width and height settings of my Mdi child form.

I have a parent form. On the left is a treeview with a splitter. I
want to open a child form up in the remaining space and size the
controls on it according to the width of the main form. So:

On the parent form:

Dim myFrm2 as Frm2

Frm2.MdiParent = Me
Frm2.Show()


On the child Form:
Private Sub Frm2_SizeChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.SizeChanged


Listbox1.Width = Me.Width - 25
Listbox1.Height = Me.Height - 25

End Sub


What this does is resize the control to the size of the parent form not
the child form. Any ideas????

This must be simple. Something I am overlooking ro doing wrong. I have
looked at the ClientSize property but still no luck. Any ideas?
 
M

Mick Doherty

On my system, the steps you showed result in exactly the behaviour I would
expect, and not what you describe, but why do you not just anchor the
listbox instead of manually resizing?
 
D

Daniel

Mick said:
On my system, the steps you showed result in exactly the behaviour I would
expect, and not what you describe, but why do you not just anchor the
listbox instead of manually resizing?

Anchor the listbox...?

So your system does not give the size of the parent form but that of the
child?
 
D

Daniel

Daniel said:
Anchor the listbox...?

So your system does not give the size of the parent form but that of the
child?

OK solved it. I had put the change in size in the SizeChanged event of
the child. When I moved them to the Load event all was great. I guess
the previous symptoms i was getting were down to user error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top