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屋!
查看全文