Moving the entire datagridview in a form.

Hi,

I want to be able to move entire datagridview in a form.

Is it possible to do it?

Thank you.
LVL 1
emi_sastraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CyberLexCommented:
you want to move its position? then DataGridView1.Left and DataGridView1.Top values changed during runtime move it around :)

cheers
Lex
0
emi_sastraAuthor Commented:
Hi Lex,

My question is not quite clear enough.
I want the user to be able to move it.

Thank you,
0
emi_sastraAuthor Commented:
Using mouse.
0
Corey ScheichDeveloperCommented:
This should get you close
Public Class Form1
 
 
    Dim DGMousPosDN As System.Drawing.Point
    Dim DgvPosDN As System.Drawing.Point
 
    Private Sub DataGridView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Left Then
 
            DGMousPosDN = Control.MousePosition
            DgvPosDN = DataGridView1.Location
 
        End If
    End Sub
 
 
    Private Sub DataGridView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseMove
        If e.Button = Windows.Forms.MouseButtons.Left Then
 
            Dim DeltaX As Integer = Control.MousePosition.X - DGMousPosDN.X
            Dim DeltaY As Integer = Control.MousePosition.Y - DGMousPosDN.Y
 
            Dim newLoc As New System.Drawing.Point(DgvPosDN.X + DeltaX, DgvPosDN.Y + DeltaY)
 
            DataGridView1.Location = newLoc
 
        End If
    End Sub
 
End Class

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
emi_sastraAuthor Commented:
Hi Corey2,

It works.

Thank you very much for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.