Excel Drag and Drop

G

Guest

I am programming Excel from C#. I want users to be able to drag and drop onto
Excel and to be able to capture the drag drop events. Spcifically, I need to
know the cell the data is being dragged to and be able to program the
givefeedback, drag over and drag drop events from the C# interface.
 
G

Guest

Peter,

I too have been looking for a way to do drag and drop from my .NET
application into Excel. Like you I haven't found a solution. However I did
discover this work around. I hope it helps.

1. First when you call DoDragDrop(), plant a unique value into the data.
For example... DoDragDrop("{DragFromMyApp}:ThedataIAmDragging", Copy);

2. In Excel, handle the Workbook SheetChanged event. Check the data for you
unique value and then invoke your code. For example:

private Void Workbook1_SheetChanged(Object sh, Range Target)
If (Target.Value.StartsWith("{DragFromMyApp}") ) //Not VBA code -- C#
string data = Target.Value;
Target.Value = null;
// Call your code here
}
}

This will be perceived by the user as though you are customizing the drag
and drop. The only drawback is that you will not be able to give feedback.
I'm still not sure how to do this.

Enjoy!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top