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

My own Drag'n drop

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

4 Replies

AD Administrator Syncfusion Team 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.

AD Administrator Syncfusion Team 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

AD Administrator Syncfusion Team 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;

AD Administrator Syncfusion Team 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

Live Chat Icon For mobile
Up arrow icon