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.

My own Drag'n drop

Thread ID:

Created:

Updated:

Platform:

Replies:

1788 Nov 26,2002 08:49 AM Nov 27,2002 05:41 AM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 26, 2002 08:49 AM

Hi ! I'm trying to implement drag'n drop of items from a listbox (a products reference list) into a grid (an invoice). If I set the AllowDrop property to true, the default behavior of the grid is to insert the dropped text into the cell choosen and to give me the control AFTER THAT in the DragDrop event. I'd like to disable this default behavior to append and fill a new row (with all product infos : ref, description, price..) after each drag'n drop action. If I set the AllowDrop property to false, my drag'n drop (DragEnter/DragOver/DragDrop) events responses are ignored. How to get full control of a drop action into this grid please ? Thanks by advance

Administrator [Syncfusion]
Replied On November 26, 2002 11:21 AM

Probably the best way to handle this is to override OnDragDrop in a derived grid. In this grid, set the AllowDrop to true, and also set the DataObjectConsumerOptions to Text only. Then in your override, just do what you want to do, and NOT call the baseclass. This should avoid the grid's processing of the drop.

Administrator [Syncfusion]
Replied On November 27, 2002 02:31 AM

Clay, I tried what you said and if I can effectively avoid the default text insertion in the cell by overriding the OnDragDrop function in a derived grid, I still can't avoid the "DragOver cell tracking" behavior of the grid : while dragging, the cell under the mouse pointer is highlighted. I would avoid this and would just have the dragging mouse cursor active while on the grid, anywhere I'm on it. Hope you can help me to solve this ! Thanks by advance

Administrator [Syncfusion]
Replied On November 27, 2002 05:23 AM

To aviod the drawing of the drop rectangle, override OnDragOver and do nothing. You would also have to override OnDragEnter and set the DrawEventArgs.Effect to the proper value if your data was present.
public class MyGridControl : GridControl
{
	protected override void OnDragDrop(DragEventArgs drgevent)
	{
		Console.WriteLine("MyGridControl.OnDragDrop");
	}

	protected override void OnDragOver(DragEventArgs drgevent)
	{
	//do nothing
	}

	protected override void OnDragEnter(DragEventArgs drgevent)
	{
		if(drgevent.Data.GetDataPresent(DataFormats.Text))
			drgevent.Effect = DragDropEffects.Move; //maybe Copy?
		else
			drgevent.Effect = DragDropEffects.None;
	}
}

Administrator [Syncfusion]
Replied On November 27, 2002 05:41 AM

Thank you Clay, it runs fine. Now I'll try to implement a row tracking in the OnDragOver event to let the user choose where he wants the product line to be inserted in the invoice...maybe with the cell style ? Thanks for your help and for your fast responses

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.

;