Centralize a form

Hi,

I have posted but I could find my post. So that I post my question again. I would like to know how to put a form in central of screen.

Regards

Tran Hong Quang




Answer this question

Centralize a form

  • SteffenRoeber

  • netpicker9

    Hi,

    try setting your form's StartPosition property to CenterScreen.

    Andrej



  • profesacutz

    Or to center a form outside of the intial form creation process. This will center the form on the screen whenever a button is clicked - irrespective of position on initial creation.

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    CenterForm()
    End Sub

    Sub CenterForm()

    Me.Top = (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2
    Me.Left = (Screen.PrimaryScreen.WorkingArea.Height - Me.Width) / 2
    End Sub

    End Class


  • Centralize a form