-
I try to set the StartupPosition property for an MDI Child form to start up in the center of the MDI form. It returns an error. Something like "Cannot set this property". I don't remember.
The child forms normally start up in the upper left hand corner of the MDI window and cascade from there.
It's not important but if anyone knows how to set the startup position for an MDI child form that would be great.
Just curious.
-
Try this.
Code:
Private Sub MDIForm_Load()
Form1.Move (Me.ScaleWidth / 2) - (Form1.Width / 2), (Me.ScaleHeight / 2) - (Form1.Height / 2)
End Sub
-
u can try these too....
Private Sub MDIChildForm_Load()
me.Move (Me.Parent.ScaleWidth / 2) - (me.Width / 2), (Me.Parent.ScaleHeight / 2) - (Me.Height / 2)
End Sub
-
I used Megatron's code. It doesn't seem to be working correctly. The child form ends up partially off of the left side of the screen. Here is the code that I used:
Private Sub MDIForm_Load()
frmUpdate.Move (Me.ScaleWidth / 2) - (frmUpdate.Width / 2), (Me.ScaleHeight / 2) - (frmUpdate.Height / 2)
End Sub
I put this in the mdiform's code. My mdiform is set to be maximized to the user's screen on load.
-
I was able to get it to work by changing it to this:
Private Sub Form_Resize()
Me.Left = (MDIForm1.Width - Me.Width) / 2
Me.Top = (MDIForm1.Height - Me.Height) / 2
End Sub