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
close icon

drag and drop gridcontrol

Hi, I am trying to implement drag and drop for the gridcontrol. I want to drag to another control. I got several problems on this: 1. The grid deletes the content of the rows which were selected. Seems to be a "move" action. How can I adjust it to have a copy that my grid is not beeing changed? 2. Turning the AllowDrop property to false disables the DragDrop/ DragEnter/ DragLeave Events so I have to use the QueryOleDataSourceData event. Is that the standard behaviour or am i doing something wrong? 3. I want the user to select rows and drag rows. 3. a) Unfortunately I have to drag a selection by positioning the mousepointer below the currentcell. I want to drag the row from each position. Do I have to use the rowheader for this or is there a property I can switch to get this behaviour? 3. b) I dont want the current cell to be visible. The content of the grid must not be changed so I just want to mark whole rows not cells. Every help would be appreciated. da5id

8 Replies

AD Administrator Syncfusion Team August 4, 2005 12:31 PM UTC

1) One way you can handle the grid.model.QueryDragDropMoveClearCells event. private void Model_QueryDragDropMoveClearCells(object sender, CancelEventArgs e) { e.Cancel = true; } 2) It is by design and is part of the .NET Framework''s Control class support. Our grid''s inherit this behavior from the framework as they are derived from Control. 3)If you do not want to edit any cells, the simplest way to get this look is to set the grid''s ListBoxSelectionMode property, and then handle the CurrentCellActivating event. In your event handler, set e.ColIndex = 0.


HL Holger Leichsenring August 4, 2005 12:44 PM UTC

thank you very much for the fast answer. perfect!


HL Holger Leichsenring August 4, 2005 03:13 PM UTC

Hi Clay, one question left from my side. Do you have an answer for 3a)? Thanks again.


AD Administrator Syncfusion Team August 4, 2005 03:22 PM UTC

The height of the selection edge is a static property that you can set. It defaults to 4. GridOleDataSourceMouseController.HitTestSelectionEdge = 12;


HL Holger Leichsenring August 4, 2005 03:31 PM UTC

Hi Clay, wow. really fast. For sure, that is a point. But, normally, the user expects to be able to drag from each row he has selected. In the syncfusion grid he only can drag from the row he has activated at last. If you dont see the "currentRow", you have to search for it with the mousepointer over all rows. How can I avoid this behaviour and switch it to a more convenient one? May the MouseOver and - on mouse click - a DoDragDrop call may solve this problem? >The height of the selection edge is a static property that you can set. It defaults to 4. >GridOleDataSourceMouseController.HitTestSelectionEdge = 12; > > >


AD Administrator Syncfusion Team August 4, 2005 04:39 PM UTC

Yes - Using the Control Drag & Drop support calling DoDragDrop should give you the behavior you want.


GK Georgi Kashev August 8, 2005 02:27 PM UTC

Unfortunatelly the mouse down event that has to start the drag&drop operation clears all other selections except the row that was currently clicked. This makes it impossible to drag a multirow selection from a row different than the lastly selected one. (Speaking about grid control with ListBoxSelectionMode = SelectionMode.MultiExtended). Do you have any idea how to solve this? Perhaps the selection change should be performed on mouse up not on mouse down?


AD Administrator Syncfusion Team August 8, 2005 02:50 PM UTC

Try handling the grid.SelectionChanging event. There you can test whether you are mousing down on a slected range, and if so, do no unselect things.
private void gridControl1_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
{
	if(e.Range.IsEmpty && 0 != (Control.MouseButtons & MouseButtons.Left))
	{
		int row, col;
		Point pt = this.gridControl1.PointToClient(Control.MousePosition);
		if(this.gridControl1.PointToRowCol(pt, out row, out col))
		{
			if(this.gridControl1.Selections.Ranges.AnyRangeContains(GridRangeInfo.Cell(row, col)))
			{
				e.Cancel = true;
			}
		}
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon