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/Drop to Grid from external source

Thread ID:

Created:

Updated:

Platform:

Replies:

6202 Aug 4,2003 02:53 PM Aug 4,2003 06:31 PM Windows Forms 2
loading
Tags: GridControl
Blaine Anderson
Asked On August 4, 2003 02:53 PM

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 04:30 PM

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 06:31 PM

Thanks!! That works!

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.

;