How to Drag and drop Data from DataGridview to Excel VSTO?

Viewed 17

I am working on Excel VSTO project. My requirement is when ribbon button click i opened window form it is having datagridview with data, I want to select some rows and drag and drop data into work sheet. can you please help the some sample code to do this requirement.

1 Answers

It is not clear what kind of form you are opening in Excel by clicking on the ribbon button. But let's suppose it is a windows form. If so, you can take a look at the Walkthrough: Performing a Drag-and-Drop Operation in Windows Forms.

To perform drag-and-drop operations within Windows-based applications you must handle a series of events, most notably the DragEnter, DragLeave, and DragDrop events. By working with the information available in the event arguments of these events, you can easily facilitate drag-and-drop operations.

Read more about that in the How to: Perform Drag-and-Drop Operations Between Applications articles.

Related