I have the following scenario:
one tree and one grid
The Nodes of the tree must be dropped into the grid, but a drop is not allowed everywhere. Is there a possibility to validate during drag which coordinates (row, col) the cell under the cursor has?
i tried it with
Private Sub GridControl1_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles GridControl1.DragOver
e.Effect = Windows.Forms.DragDropEffects.All
Dim lrange As GridRangeInfo
lrange = GridControl1.PointToRangeInfo(New System.Drawing.Point(e.X, e.Y))
But allways the last cell is selected.
Thanks for your help.
ADAdministrator Syncfusion Team March 12, 2004 04:11 AM
There is a problem in using Windows Forms Drag events with the grid. The problem is that the grid also has some objects that listen to these events, and there is no guarantee your listener will be hit before/after the grid''s listener. So, there is no way to ''know'' whose settings are going to take effect when several listeners subscribe to the same event. This is a generic Windows Forms events problem, and is one of the negatives (or positives depending on your point of view???) to the event architecture.
One solution to this problem is to not use events, but to derive the control and override the accopanying OnEventXXXX method that, by convention, is provided by the Framework. This way, you can control what setting is returned. Below is code that does not let you drop on row 3. (The range indicator frame will not move into row 3).
Protected Overrides Sub OnDragOver(drgevent As System.Windows.Forms.DragEventArgs)
Dim pt As Point = Me.PointToClient(New Point(drgevent.X, drgevent.Y))
Dim row, col As Integer
If Me.PointToRowCol(pt, row, col, 1) Then
If row = 3 Then
drgevent.Effect = DragDropEffects.None
End Sub ''OnDragOver