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.

drag and drop gridcontrol

Thread ID:

Created:

Updated:

Platform:

Replies:

32602 Aug 4,2005 07:26 AM Aug 8,2005 10:50 AM Windows Forms 8
loading
Tags: GridControl
Holger Leichsenring
Asked On August 4, 2005 07:26 AM

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

Administrator [Syncfusion]
Replied On August 4, 2005 08:31 AM

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.

Holger Leichsenring
Replied On August 4, 2005 08:44 AM

thank you very much for the fast answer. perfect!

Holger Leichsenring
Replied On August 4, 2005 11:13 AM

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

Administrator [Syncfusion]
Replied On August 4, 2005 11:22 AM

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

Holger Leichsenring
Replied On August 4, 2005 11:31 AM

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

Administrator [Syncfusion]
Replied On August 4, 2005 12:39 PM

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

Georgi Kashev
Replied On August 8, 2005 10:27 AM

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?

Administrator [Syncfusion]
Replied On August 8, 2005 10:50 AM

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

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.

;