AD
Administrator
Syncfusion Team
March 12, 2004 09:11 AM UTC
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
Return
End If
End If
MyBase.OnDragOver(drgevent)
End Sub ''OnDragOver