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

Drag/Drop to Grid from external source

Thread ID:





6202 Aug 4,2003 06:53 PM UTC Aug 4,2003 10:31 PM UTC WinForms 2
Tags: GridControl
Blaine Anderson
Asked On August 4, 2003 06:53 PM UTC

I am trying to drop an object onto a Grid Control. I set up the drag/drop operation in Form1 of an MDI app like this: private void songListView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { String s="Testing..."; songListView.DoDragDrop(s.ID.ToString(), DragDropEffects.Copy); } Form2 includes the following: gridControl1.AllowDrop = true; gridControl1.Model.Options.DragDropDropTargetFlags = GridDragDropFlags.Text; private void gridControl1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if(e.Data.GetDataPresent(DataFormats.Text, true)) e.Effect = DragDropEffects.Copy; else e.Effect = DragDropEffects.None; } I verified that the DragEnter handler IS being called correctly. However, my mouse cursor never changes to the "Allow Drop" mode anf gridControl1_DragDrop() does not get called when I drop. Any Ideas???

Administrator [Syncfusion]
Replied On August 4, 2003 08:30 PM UTC

Try this. It creates a DataObject and sets the DataFormats.Text datatype so it could be tested in the grid. It also specifies DragDropEffects.All so you do not have to press the shift to do the drop. Since the source is responsible for deleting the moved object, it will not do any harm to accept all actions in the grid.
private void Form1_MouseDown(object sender, MouseEventArgs e)
	String s = "Testing...";
	DataObject data = new DataObject(DataFormats.Text, s);
	this.DoDragDrop(data, DragDropEffects.All);

Blaine Anderson
Replied On August 4, 2003 10:31 PM UTC

Thanks!! That works!


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