I am trying to implement an OLE D&D on a GridDataBoundGrid. Everything is working great except for erasing the old drop target line. Per examples provided by you, I''ve come up with the following DragOver handler.
Private Sub gdbdOrders_DragOver(ByVal sender As Object, ByVal e As DragEventArgs) Handles gdbgOrders.DragOver
If draggingRows Then
Dim row As Integer, col As Integer
Dim pt As Point = New Point(e.X, e.Y)
pt = gdbgOrders.PointToClient(pt)
gdbgOrders.PointToRowCol(pt, row, col)
''Evaluate position and draw drop target
Dim cellBounds As Rectangle = New Rectangle(gdbgOrders.ViewLayout.ClientRowColToPoint(row, 0, GridCellSizeKind.ActualSize), New Size(gdbgOrders.GetColWidth(0), gdbgOrders.GetRowHeight(row)))
If Not (cellBounds.Equals(oldDropRect)) Then
Dim pt1 As Point
Dim pt2 As Point
Dim g As Graphics = gdbgOrders.CreateGridGraphics()
Dim p As Pen = New Pen(Color.FromArgb(100, Color.Blue), 6)
Dim py As Pen = New Pen(Color.FromArgb(100, Color.Yellow), 6)
If (Not oldDropRect.IsEmpty) Then
''''''This is what I am trying to use to clear the drop target line
''''''This is verifying that I have the correct coordinates in oldDropRect. It successfully overpaints the blue drop target
pt1 = New Point(oldDropRect.Left, oldDropRect.Top + 3)
pt2 = New Point(oldDropRect.Right, oldDropRect.Top + 3)
g.DrawLine(py, pt1, pt2)
oldDropRect = cellBounds
pt1 = New Point(cellBounds.Left, cellBounds.Top + 3)
pt2 = New Point(cellBounds.Right, cellBounds.Top + 3)
''p.EndCap = LineCap.Flat
''p.EndCap = LineCap.DiamondAnchor
''p.StartCap = LineCap.DiamondAnchor
g.DrawLine(p, pt1, pt2)
dropTargetRow = row
The example I followed was for a GridControl and worked as expected. The troublesome lines are:
It works for the GridControl but not a GDBG. The code that draws the yellow line was to validate that the oldDropRect had sane coordinates. I correctly overdraws the previous target.
I use ...
... im DragDrop to successfully remove all target line from the grid.
Any ideas why it doesn''t work from DragOver? It''s interesting that I can draw graphics but not trigger a paint event to clear the old target.