Copy DataGridView contents to clipboard
38,923
Solution 1
Have you added this line?
myDataGrid.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
Take a look at this MSDN article for a working sample.
Solution 2
If you use Microsoft Visual Studio You can do it in Design File. Your Gridview ->right Click->Propeties->ClipBoard Copy Mode->EnableWithoutHeaderText
Related videos on Youtube
Author by
Karl
Updated on July 09, 2022Comments
-
Karl almost 2 years
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.
Any suggestions?