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

GridControl: Drag and Drop, custom data.

Thread ID:

Created:

Updated:

Platform:

Replies:

17221 Aug 3,2004 08:21 PM Aug 6,2004 12:22 AM Windows Forms 5
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 3, 2004 08:21 PM

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

Administrator [Syncfusion]
Replied On 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.

Administrator [Syncfusion]
Replied On 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); }

Administrator [Syncfusion]
Replied On 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 ?

Administrator [Syncfusion]
Replied On 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.

CONFIRMATION

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.

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.

;