将DataGridView内容复制到剪贴板 [英] Copy DataGridView contents to clipboard
本文介绍了将DataGridView内容复制到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想复制DataGridView的内容并将其粘贴到Excel中。我试过:
I want to copy the contents of a DataGridView and paste it in Excel. I tried:
myDataGrid.SelectAll();
DataObject dataObj = myDataGrid.GetClipboardContent();
Clipboard.SetDataObject(dataObj, true)
但这只是没有任何东西。
But this just pastes nothing.
任何建议?
推荐答案
你添加了这行吗?
myDataGrid.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
看看这个MSDN文章的工作示例。
这篇关于将DataGridView内容复制到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文