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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridControl: Drag and Drop, custom data.

Thread ID:





17221 Aug 4,2004 12:21 AM UTC Aug 6,2004 04:22 AM UTC WinForms 5
Tags: GridControl
Administrator [Syncfusion]
Asked On August 4, 2004 12:21 AM UTC

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.

Administrator [Syncfusion]
Replied On August 4, 2004 05:16 AM UTC

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;

Administrator [Syncfusion]
Replied On August 5, 2004 02:02 AM UTC

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.

Administrator [Syncfusion]
Replied On August 5, 2004 05:34 AM UTC

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); }

Administrator [Syncfusion]
Replied On August 6, 2004 02:04 AM UTC

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 ?

Administrator [Syncfusion]
Replied On August 6, 2004 04:22 AM UTC

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.


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

Live Chat Icon For mobile
Live Chat Icon