Hello,
When my program is first started I want to display a form as dialog.
Now I want that form in the center of my screen ... but I can't make it happen.
I tried already several things.
and combinations of them...
anyone can see what I'm doing wrong?
kind regards,
Wesley
When my program is first started I want to display a form as dialog.
Now I want that form in the center of my screen ... but I can't make it happen.
I tried already several things.
Code:
Dim fOptions As New frmOptions
fOptions.StartPosition = FormStartPosition.Manual
Dim x As Integer = Screen.PrimaryScreen.WorkingArea.Width / 2 - fOptions.Width / 2
Dim y As Integer = Screen.PrimaryScreen.WorkingArea.Height / 2 - fOptions.Height / 2
fOptions.Location = New Point(x, y)
Dim oResult As DialogResult = fOptions.ShowDialog
Code:
Private Sub frmOptions_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
Try
Dim x As Integer = Screen.PrimaryScreen.WorkingArea.Width / 2 - Me.Width / 2
Dim y As Integer = Screen.PrimaryScreen.WorkingArea.Height / 2 - Me.Height / 2
Me.DesktopLocation = New Point(x, y)
Catch ex As Exception
End Try
End Sub
Code:
Private Sub frmOptions_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
Try
Me.Left = Screen.PrimaryScreen.WorkingArea.Width / 2 - Me.Width / 2
Me.Top = Screen.PrimaryScreen.WorkingArea.Height / 2 - Me.Height / 2
Catch ex As Exception
End Try
End Sub
Code:
Private Sub frmOptions_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim x As Integer = Screen.PrimaryScreen.WorkingArea.Width / 2 - Me.Width / 2
Dim y As Integer = Screen.PrimaryScreen.WorkingArea.Height / 2 - Me.Height / 2
Me.Location = New Point(x, y)
anyone can see what I'm doing wrong?
kind regards,
Wesley