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

My own Drag'n drop

Thread ID:





1788 Nov 26,2002 01:49 PM UTC Nov 27,2002 10:41 AM UTC WinForms 4
Tags: GridControl
Administrator [Syncfusion]
Asked On November 26, 2002 01:49 PM UTC

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 04:21 PM UTC

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 07:31 AM UTC

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 10:23 AM UTC

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)

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

	protected override void OnDragEnter(DragEventArgs drgevent)
			drgevent.Effect = DragDropEffects.Move; //maybe Copy?
			drgevent.Effect = DragDropEffects.None;

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

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


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