How to select a target datagrid row in dragdrop operation?

G

Guest

I have a master/detail form with 2 datagrids: selecting (by clicking) a row on the master grid updates the detail grid.
I have a requirement to drag rows from the detail grid and drop them on a master row to initiate a data move routine

Q. How do I select the traget row while in the DragOver event

Thanks in advanc
Howard
 
D

DotNetJunkies User

This is how I dropped into a specific field but it shows how to get the row. What a round-about way to get it done!

Private Sub dgInputFields_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles dgInputFields.DragDrop
Dim oFormPoint As Point
Dim oHitTest As System.Windows.Forms.DataGrid.HitTestInfo

If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Copy
oFormPoint = dgInputFields.PointToClient(New Point(e.X, e.Y))
oHitTest = dgInputFields.HitTest(oFormPoint.X, oFormPoint.Y)
dsControl.Tables("PointsBySubSystem").Rows(oHitTest.Row)("MappedField") = e.Data.GetData(DataFormats.Text).ToString
Else
e.Effect = DragDropEffects.None
End If
End Sub

Good luck,
Ken
 
D

DotNetJunkies User

This is how I dropped into a specific field but it shows how to get the row. What a round-about way to get it done!

Private Sub dgInputFields_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles dgInputFields.DragDrop
Dim oFormPoint As Point
Dim oHitTest As System.Windows.Forms.DataGrid.HitTestInfo

If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Copy
oFormPoint = dgInputFields.PointToClient(New Point(e.X, e.Y))
oHitTest = dgInputFields.HitTest(oFormPoint.X, oFormPoint.Y)
dsControl.Tables("PointsBySubSystem").Rows(oHitTest.Row)("MappedField") = e.Data.GetData(DataFormats.Text).ToString
Else
e.Effect = DragDropEffects.None
End If
End Sub

Good luck,
Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top