Results 1 to 4 of 4

Thread: Centering a form?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2002
    Posts
    210

    Centering a form?

    I don't see any centering property for a form, so I'm guessing that I'll have to use a code to do that.

    In VB6, it was
    VB Code:
    1. Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
    but VB.Net doesn't seem to like it.

    Could anyone please convert that VB6 code to VB.Net?

    Thanks in advance.

  2. #2
    Lively Member hbandarra's Avatar
    Join Date
    Aug 2002
    Location
    Lisbon, PT
    Posts
    66

    Red face StartPosition

    On Developer Studio, select the form and change the property "StartPosition"

  3. #3
    New Member
    Join Date
    Oct 2002
    Location
    London
    Posts
    1
    Can all be done with a property now but if you want to
    do it the hard way then:-

    Public Sub centerControl(ByRef c As Control)
    c.Left = (Screen.PrimaryScreen.WorkingArea.Width - c.Width) / 2
    c.Top = (Screen.PrimaryScreen.WorkingArea.Height - c.Height) / 2
    c.Refresh()
    End Sub

    Hover

  4. #4
    Member Vahid's Avatar
    Join Date
    Aug 2002
    Location
    Iran
    Posts
    37
    Form has two Methods CenterParent and CenterScreen that can help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width