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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Drag&Drop with custom MouseController

Thread ID:





71419 Jan 30,2008 09:16 AM UTC Feb 13,2008 03:11 PM UTC WinForms 2
Tags: GridControl
Andreas Gfeller
Asked On January 30, 2008 09:16 AM UTC

I have to drag&drop entire rows inside a grid. We do NOT use row and column headers for other reasons.

So I've found a solution here with a custom mouse controller:


That work's pretty fine so far. Regardless of the clicked column, I'm always selecting the entire row with the red frame.

An important fact in our grid is:

Not every row is allowed for dropping. Only a certain number of rows inside the grid are targets. Outside this range, dropping is not allowed.

In my custom mouse controller in the MouseMove-Eventhandler, I'm taking care of that. The red dragging selection can not go beyond an upper an lower row.

That works fine for the red frame. But when the mouse goes beyond this borders, the old gray/dotted dragging selection becomes visible. And this looks not good for the user.

Is it possible to definitively suppress the old (default) dragging selection frame?


haneefm [Syncfusion]
Replied On February 8, 2008 07:03 PM UTC

Hi AndreasG,

Bydefault , GridControl calls the OutlineDropTargetRange method of GridOleDropTarget class to color the OleDropTarget rectangle. If you want to change the color of the OleDropRectangle, you need to derive GridOleDropTarget class and override the OutlineDropTargetRange method. Blow are the codes that shows this task.

public class MyGrid : GridControl
public MyGrid()
: base()
protected override GridOleDropTarget CreateOleDropTarget(GridControlBase grid, int flags)
MyGridOleDropTaget target = new MyGridOleDropTaget(grid);
return target;

public class MyGridOleDropTaget : GridOleDropTarget
public MyGridOleDropTaget(GridControlBase grid)
: base(grid)

protected override void OutlineDropTargetRange(Point point, bool bEraseOld, bool bDrawNew)
int row,col;
if (this.Grid.PointToRowCol(point, out row, out col))
using (Graphics g = this.Grid.CreateGridGraphics())
int rowOffset = this.Grid.Model.DragDropData.dndRowOffset;
int colOffset = this.Grid.Model.DragDropData.dndColOffset;
Rectangle bounds = this.Grid.RangeInfoToRectangle(GridRangeInfo.Cells(row, col, row + rowOffset, col + this.Grid.Model.DragDropData.dndColOffset));
g.DrawRectangle(new Pen(Color.Red, 3f), bounds);

Best regards,

Andreas Gfeller
Replied On February 13, 2008 03:11 PM UTC

Thank you Haneef, this is EXACTLY the code I was looking for!



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon