We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Repainting a GDBG while dragging

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 '''''' ''gdbgOrders.Invalidate(oldDropRect, True) ''gdbgOrders.Update() '''''' '''''' ''''''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) py.Dispose() End If 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) g.Dispose() p.Dispose() dropTargetRow = row End If End If End Sub 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 ... gdbgOrders.Invalidate() gdbgOrders.Update() ... 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. Thanks, Doug

3 Replies

AD Administrator Syncfusion Team August 31, 2004 06:58 PM UTC

Just something to try. After this line, gdbgOrders.Invalidate(oldDropRect, True) try calling Application.DoEvents() to see if that will trigger the update.

DL Doug Lind September 1, 2004 10:48 AM UTC

That didn''t work Clay. It paints one line and locks up. I believe it is due to this warning from Microsoft: CAUTION Calling this method can cause code to be re-entered if a message raises an event. Since I''m doing an invalidate, my guess is the handler is getting rentered. I tried just grid.refresh and grid.update with DoEvents and got the same result. DoEvents by itself does not cause the reentry so it must be the event being raise in conjunction with DoEvents. I''m looking into getting the row header background color and drawing over the old target. Any thing else you can think of to try? Thanks, Doug

AD Administrator Syncfusion Team September 1, 2004 11:27 AM UTC

Maybe the there is an open call to grid.BeginUpdate that is preventing the painting. So, maybe this will work. if gdbgOrders.Updating Then gdbgOrders.CancelUpdate() gdbgOrders.Invalidate(oldDropRect, True) gdbgOrders.Update()

Live Chat Icon For mobile
Up arrow icon