I have GUI which is splitted two piece with SplitContainer element. One of is navigation panel one of is workspace panel. When i open the app on start-up there's a new form appears (Show.Dialog()) for Welcomes user but i would like to loads it center of the workspace panel.
Is there anybody experienced it how it can be solved ?
Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
frmWelcome.ShowDialog()
End Sub
Assuming that
Panel2
is yourWorkSpace
panel, use thePanel.PointToScreen
method to calculate the screen coordinates offrmWelcome
and position it in the middle.Be sure to set your
frmWelcome.StartPosition = Manual
, in the designer or in the constructor.Here I'm using the
Shown
event, to be sure that the pre-set positions inMainForm
are already set.You can use the properties on forms to do this.
set the frmWelcome form property
StartPosition
toCenterScreen
.If you want it center of the screen opening it, you will have to setup
MDI
but from there you can dofrmWelcome.ShowDialog(Me)
and set the propertyStartPosition
toCenterParent
.Hope this helps!