简体   繁体   English

如何将数据从 DataGridview 拖放到 Excel VSTO?

[英]How to Drag and drop Data from DataGridview to Excel VSTO?

I am working on Excel VSTO project.我正在研究 Excel VSTO 项目。 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.我的要求是当功能区按钮单击时,我打开 window 表单,它具有带有数据的 datagridview,我想 select 一些行并将数据拖放到工作表中。 can you please help the some sample code to do this requirement.你能帮助一些示例代码来完成这个要求吗?

It is not clear what kind of form you are opening in Excel by clicking on the ribbon button.通过单击功能区按钮,尚不清楚您在 Excel 中打开了哪种表格。 But let's suppose it is a windows form.但是让我们假设它是一个 windows 形式。 If so, you can take a look at the Walkthrough: Performing a Drag-and-Drop Operation in Windows Forms .如果是这样,您可以查看演练:在 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.要在基于 Windows 的应用程序中执行拖放操作,您必须处理一系列事件,最值得注意的是 DragEnter、DragLeave 和 DragDrop 事件。 By working with the information available in the event arguments of these events, you can easily facilitate drag-and-drop operations.通过使用这些事件的事件 arguments 中可用的信息,您可以轻松地进行拖放操作。

Read more about that in the How to: Perform Drag-and-Drop Operations Between Applications articles.如何:在应用程序之间执行拖放操作文章中阅读有关此内容的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM