Please help

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Please help
muttley1968
Does any one know how to make a hole form dock i would like to make my form dock to the top of the screen or the bottom of the screen if anyone knows how to do this would you please be able to enlighten me
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: Please help
XTechVB
add this under Public Class
Code: Select all
 Public Enum Position
        Top_Right = 1
        Top_Centre = 2
        Top_Left = 3
        Middle_Right = 4
        Middle_Center = 5
        Middle_Left = 6
        Bottom_Right = 7
        Bottom_Center = 8
        Bottom_Left = 9
    End Enum
    Private Sub WindowPossition(ByVal pos As Position)
        If Me.WindowState = FormWindowState.Normal Or Me.WindowState = FormWindowState.Minimized Then
            Select Case pos
                Case Is = Position.Bottom_Left
                    Me.Location = New Point(0, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)

                Case Is = Position.Bottom_Center
                    Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2, Screen.PrimaryScreen.WorkingArea.Height - Me.Height)

                Case Is = Position.Bottom_Right
                    Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width), Screen.PrimaryScreen.WorkingArea.Height - Me.Height)

                Case Is = Position.Middle_Center
                    Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2, (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2)

                Case Is = Position.Middle_Left
                    Me.Location = New Point((0), (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2)

                Case Is = Position.Middle_Right
                    Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width, (Screen.PrimaryScreen.WorkingArea.Height - Me.Height) / 2)

                Case Is = Position.Top_Centre
                    Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width) / 2, 0)

                Case Is = Position.Top_Left
                    Me.Location = New Point(0, 0)

                Case Is = Position.Top_Right
                    Me.Location = New Point((Screen.PrimaryScreen.WorkingArea.Width - Me.Width), 0)
            End Select
        End If
    End Sub
then you can change position like this
Code: Select all
WindowPossition(Position.Bottom_Center)
You can find me on Facebook or on Skype mihai_92b
User avatar
muttley1968
Hardcore Programmer
Hardcore Programmer
Posts: 622
Joined: Thu Jun 17, 2010 11:54 pm

Re: Please help
muttley1968
That works a treat thank you very mutch
3 posts Page 1 of 1
Return to “Coding Help & Support”