From dePoPo.net

Loading a main fom centered on the screen

Posted in: Forms and Grids
By dePoPo
Jun 23, 2009 - 11:45:52 AM

To load a form centered and sized on the screen you can put the code below in the form_load event.

This sample will load the form at 80% of the screen size

        ' --- Load the form at 80% of the screen size, centered
        Dim n_screenwith As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim n_screenheight As Integer = Screen.PrimaryScreen.Bounds.Height
        Me.Width = 0.8 * n_screenwith
        Me.Height = 0.8 * n_screenheight
        Me.WindowState = FormWindowState.Normal
        Me.Location = New Point((n_screenwith - Me.Width) / 2, (n_screenheight - Me.Height) / 2)

© Copyright 2010 by dePoPo.net