Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- ''' How To Use
- '''
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim CorrM As MovableGridView = New MovableGridView(DataGridView1)
- End Sub
- '''
- ''' Coded By CorrM 8/2/2017
- '''
- Public Class MovableGridView
- Private WithEvents _Gridv As DataGridView
- Private CanMove As Boolean = False
- Private MouseLoc As Point
- Sub New(ByRef Gridv As DataGridView)
- _Gridv = Gridv
- End Sub
- Private Sub Gridv_MouseDown(sender As Object, e As MouseEventArgs) Handles _Gridv.MouseDown
- If e.Button = MouseButtons.Left Then
- CanMove = True
- MouseLoc.X = e.X
- MouseLoc.Y = e.Y
- End If
- End Sub
- Private Sub Gridv_MouseUP(sender As Object, e As MouseEventArgs) Handles _Gridv.MouseUp
- CanMove = False
- End Sub
- Private Sub _Gridv_MouseMove(sender As Object, e As MouseEventArgs) Handles _Gridv.MouseMove
- If CanMove Then
- Dim MoveX As Integer = e.X - MouseLoc.X
- Dim MoveY As Integer = e.Y - MouseLoc.Y
- _Gridv.Location = New Point(_Gridv.Location.X + MoveX, _Gridv.Location.Y + MoveY)
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement