• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • Last Modified:

VB.net open Windows Form at point on DataGridView drag drop


I am opening a Windows form in the DragDrop event over a DataGridView. I have done a hit test. How do I open the form at the point where the drag drop occurs using this information?

  Private Sub DataGridView1_DragDrop(sender As Object, e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop
            Dim oCellAddress As String

            '** NOTE - Find X and Y coorinates or Row and Column index: so can drag into an individual cell or a row
            '   The following code puts whatever text is sent into the destination cell
            Dim p As Point = Me.DataGridView1.PointToClient(New Point(e.X, e.Y))
            Dim hitTest As DataGridView.HitTestInfo = DataGridView1.HitTest(p.X, p.Y)
            Dim oRowIndex As Integer = hitTest.RowIndex
            Dim oColumnIndex As Integer = hitTest.ColumnIndex

              Dim Form_PickQuery As New frmPickQuery
Murray Brown
Murray Brown
1 Solution
Luis PérezSoftware Architect in .NetCommented:
What you need to do is:

Dim Form_PickQuery As New frmPickQuery
Form_PickQuery.StartPosition = FormStartPosition.Manual
Form_PickQuery.Left = e.X
Form_PickQuery.Top = e.Y

Open in new window

Hope that helps.
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now