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

Rearrange the grid using DragDrop

Hi, I''m using the gridcontrol in 3.3.0.0. I want to rearrange the grid using DragDrop. However, since the grid data in front of drop will disappear if DragDrop Event is used, it cannot rearrange. Isn''t there any Event which memorizes only the cell position to which DragDrop came, without updating GridData? Thanks

3 Replies

AD Administrator Syncfusion Team November 25, 2005 02:50 AM UTC

So you want to start a D&D in a grid, but then not let the grid complete the drop? If so, you can derive the grid and override OnDargDrop and not call the base class. To see where the drag started you can handle the QueryOleDataSourceData event.
public class MyGridControl : GridControl
{
	public MyGridControl()
	{
		this.Model.QueryOleDataSourceData += new GridQueryOleDataSourceDataEventHandler(Model_QueryOleDataSourceData);
	}
	protected override void OnDragDrop(DragEventArgs drgevent)
	{
		//base.OnDragDrop (drgevent);
		this.Refresh();
		Console.WriteLine("dropped");
			
	}
	private void Model_QueryOleDataSourceData(object sender, GridQueryOleDataSourceDataEventArgs e)
	{
		Console.WriteLine(e.RangeList);
	}
}


DC DCnagai November 28, 2005 01:36 AM UTC

Thanks Clay Burch. I want to know not only where the drag started but where it dropped. Thanks,


AD Administrator Syncfusion Team November 28, 2005 09:09 AM UTC

In OnDragDrop, you can use code like:
int row, col;
Point pt = this.PointToClient(Control.MousePosition);
if(this.PointToRowCol(pt, out row, out col))
{
    //row and col is the drop cell
}

Loader.
Live Chat Icon For mobile
Up arrow icon