StephleHardi
2024-04-09T07:39:27Z
Hello Igor I have a small problem that I can't solve During a "drag and drop" operation.

I would like to select the cell (or row) hovered over during the DragOver event (and therefore highlight it) so that the user can clearly see in which cell the data will be copied.

Here is what I tried but without success

Private Sub IG_1_CellMouseDown(sender As Object, e As iGCellMouseDownEventArgs) Handles IG_1.CellMouseDown

Dim DD = IG_1.CellValues(e.RowIndex, e.ColIndex)
IG_1.DoDragDrop(DD, DragDropEffects.Copy)

End Sub


Private Sub IG_2_DragOver(sender As Object, e As DragEventArgs) Handles IG_2.DragOver

e.Effect = DragDropEffects.Copy

With RowMode = False

IG_2.PerformAction(iGActions.DeselectAllcells)

Dim CL As Integer = IG_2.Cells.FromPoint(e.X, e.Y).RowIndex
IG_2.SetCurCell(CL, 0) >>>> ERROR

OR with RowMode = True

IG_2.PerformAction(iGActions.DeselectAllRows)
Dim R As iGRow = IG_2.Rows.FromY(e.Y)
R.Selected = True >> It works but the line under the mouse never corresponds to reality
End Sub

Please tell me what is wrong
Very cordially
Stephane

Igor/10Tec
2024-04-09T13:44:12Z
The DragOver event is not an event provided by iGrid itself. This is one of the events inherited from the base Control  class. See this page in the Microsoft documentation:

https://learn.microsoft....s.forms.control.dragover 

The X and Y coordinates provided by the corresponding fields of the event arguments are in the screen coordinates. You must convert them to the client coordinates if you want to use them with iGrid methods. There is a note and example on that page dedicated to the DragOver event explaining how to use the Contro.PointToClient()  method for that.
StephleHardi
2024-04-09T14:17:30Z
everything is now correct

I hadn't thought about it because my code worked perfectly with the MouseMove event

Thank you very much,
Users browsing this topic