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

GridControl: Drag and Drop, custom data.

Hello. I have the Grid control in virtual mode.I configure for selecting rows only. By default, Drag and Drop available and it drags text fields of selected (and active) row. But the question is: how to drag my custom data (for example, only collection of some values, associated with selected rows, not text)? I hope it is possible to override some methods, but cannot find how to implement that functionality. Please help me :) Vadim.

5 Replies

AD Administrator Syncfusion Team August 4, 2004 01:16 AM

The grid has very extensible OLE D&D support. So, you have several way to approach your problem. The simplest way to add a custom data object to the D&D operation is to handle the QueryOleDataSourceData event. Here, an event arg will pass the DataObject and you can just add your custom format and daat in this event. Below is a little snippet that puts a specific string in the data object,
private void gridModel_QueryOleDataSourceData(object sender, GridQueryOleDataSourceDataEventArgs e)
{
	e.DataObject.SetData(DataFormats.Text, "aaaaaaa");
	e.Handled = true;
	e.Result = true;
}
            


AD Administrator Syncfusion Team August 4, 2004 10:02 PM

Ok, thank you. But, can you help me once again. It is not clear for me how to get currently dragged row (index of the row in virtual grid)from specified handler.


AD Administrator Syncfusion Team August 5, 2004 01:34 AM

Try this code. int row, col; Point pt = this.gridControl1.PointToClient(Control.MousePosition); if(this.gridControl1.PointToRowCol(pt, out row, out col, -1)) { GridRangeInfo range = this.gridControl1.Selections.Ranges.ActiveRange; Console.WriteLine("drag started at ({0},{1})", row, col); Console.WriteLine("selection is {0}", range); }


AD Administrator Syncfusion Team August 5, 2004 10:04 PM

Ok, it works :) Another problem accures when I drop my data somewhere (form of the application). In the same time application become frozen for about 2 seconds. Some internal exceptions occures but they''re catched by grid. In the Output window: catched at Syncfusion.Windows.Forms.Grid.GridModel.SetCellInfo(Int32 rowIndex, Int32 colIndex, GridStyleInfo style, StyleModifyType modifyType, Boolean dontRaiseSaveCellInfoEvent, Boolean copyReferenceOnly) in :line 0 catched at Syncfusion.Windows.Forms.Grid.GridModel.ClearCells(GridRangeInfoList rangeList, Boolean clearStyle) in :line 0 catched at Syncfusion.Windows.Forms.ScrollControl.RaiseCancelMouseEvent(MouseEventArgs e, CancelMouseDelegate d) in :line 0 How to avoid exceptions above ?


AD Administrator Syncfusion Team August 6, 2004 12:22 AM

The default behavior of an OLE D&D is to do a Move operation. This means the source needs to clear the data when it gets dropped. The way the source knows what happens is provided by the DragDrop event args in the targets DragDrop event handler. So, in your form''s handler try setting e.Effect = DragDropEffects.Copy. This is retruned to the source as the return value of the DoDragDrop call.

Loader.
Live Chat Icon For mobile
Up arrow icon