Center in Child

  • Thread starter Thread starter vul
  • Start date Start date
V

vul

I have an MDI application with a ListBar on the left side of MDI form. All
child forms are displayed inside of the client area of MDI form.
Now I need to display a third form from a child and center it related to the
calling Child form. I cannot find the way to do that.

Any help please
Al
 
I tried to set
Me.Parent = Supplier (Supplier is a caller form) and got an error:
Top-level control cannot be added to a control.

ParentForm property is ReadOnly, so I cannot use it.
Then I tried
Me.Owner = Supplier

It doesn't center the third form in the calling one. It centers in MDI

Thank you

Al
 
hi Al,

try these and let me know:

'SOLUTION 1:
'ChildOfMDIChild is owned MDIChild: stays on top
'of it and moves independently

Dim ChildOfMDIChild1 As New Form
With ChildOfMDIChild1
.Owner = Me
.StartPosition = FormStartPosition.Manual
.Location = New Point(.Owner.Left + (.Owner.Width - .Width)
\ 2, _
.Owner.Top + (.Owner.Height -
..Height) \ 2)
.Show()
End With


'SOLUTION 2:
'ChildOfMDIChild is within MDIChild and moves with it
'cannot exit from MDIChild (behaves somehow like a control)

Dim ChildOfMDIChild2 As New Form
With ChildOfMDIChild2
.TopLevel = False
.Parent = Me
.Location = New Point((.Parent.Width - .Width) \ 2, _
(.Parent.Height - .Height) \ 2)
.Show()
End With



-tom


Al ha scritto:
 
Thanbk you Tom
No success.
First solution centers the third form inside of MDI, not the child who calls
a third form. It's because the child has Location 0,0 within MDI, but as I
said in my initial post, there is a List Bar on the left side in MDI.

The second solution doesn't work too by many reasons.
My third form must be modal, and I use ShowDialog. ShowDialog is not allowed
for not top level forms, if I try to use Show, the form just doesn't appear.
I don't know why.

I was hoping that there is a simple solution, like the change one or 2
settings. I've been thinking about calculation for Location of the third
form, but decided to look for a more elegant solution.
At least temporarily I'll use your approach - I'll calculate Location for
the third form.

Thank you
Al
 
Well ... that's really strange. I jave just retried it on my pc (using
vb2003) and the first solution centers the third form inside its owner,
not the MDI form, like you report (?). If I move the child the form and
open the form, it is always centered within the MDI child.

Are you sure you have pasted exactly the same code. Note that is
important the sequence of statements and .StartPosition =
FormStartPosition.Manual...

- tom

Al ha scritto:
 
Back
Top