Can anyone point me to an article/example of how to do a copy from a
datagridview?
I have a datagridview in which a user can select a block of cells (not
necessarily complete rows). I would like them to be able to copy this
info by either a right-click (context menu) or CTL-C.
Any help would be greatly appreciated.
Sincerely,
Glen
Glen - 28 Oct 2005 19:57 GMT
Stumbled across the solution. Too easy...
Private Sub mnuCopy_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles mnuCopy.Click
If Me.SelectedCells.Count <= 0 Then Exit Sub
If MessageBox.Show("Do you want to copy the header titles as
well?", "Header Titles", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) = DialogResult.Yes Then
Me.ClipboardCopyMode =
DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
Else
Me.ClipboardCopyMode =
DataGridViewClipboardCopyMode.EnableWithoutHeaderText
End If
Clipboard.SetDataObject(Me.GetClipboardContent())
End Sub