Move Panel at run time Using Mouse Buttons


  • #Region " Mouse Dragging "



    Private Sub pnlHeader_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlHeader.MouseMove
    If e.Button = Windows.Forms.MouseButtons.Left Then

    Dim dx As Integer = Math.Abs(e.X - Px.X)
    Dim dy As Integer = Math.Abs(e.Y - Px.Y)
    Dim ParentForm As Form = MyBase.Parent.Parent.Parent

    If Px.X > e.X Then
    ParentForm.Left = ParentForm.Left - dx
    End If
    If Px.X < e.X Then
    ParentForm.Left = ParentForm.Left + dx


    End If
    If Px.Y > e.Y Then
    ParentForm.Top = ParentForm.Top - dy
    End If
    If Px.Y < e.Y Then
    ParentForm.Top = ParentForm.Top + dy
    End If

    End If
    End Sub


    Private Px As New Point
    Private Sub pnlHeader_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlHeader.MouseDown
    If e.Button = Windows.Forms.MouseButtons.Left Then
    Px = e.Location
    DrawHeader(True)


    End If
    End Sub


    Private Sub pnlHeader_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pnlHeader.MouseUp
    If e.Button = Windows.Forms.MouseButtons.Left Then
    Call DrawHeader()
    End If

    End Sub

    #End Region


    for further details and related topics http://www.codecorner.somee.com/

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week