Articles in this section
Category / Section

How to copy the selected range of cells to the clipboard in WinForms GridControl and GridDataBoundGrid ?

2 mins read

Copy the selected range of cells to the clipboard

In WinForms GridControl, you can copy the text programmatically from a selected range of cells to the clipboard by using the CopyTextToClipboard method.

C#

// To copy selected ranges in grid control.
bool val = this.gridControl1.CutPaste.CopyTextToClipboard(this.gridControl1.Selections.Ranges);
Console.WriteLine(" Selected Range of cells(GridControl)are in Clipboard. This is" + val);
MessageBox.Show("Data copied");
//To copy selected range of cells to clipboard in GridDataBoundGrid.
bool val = this.gridDataBoundGrid1.Model.CutPaste.CopyTextToClipboard(this.gridDataBoundGrid1.Selections.Ranges);
Console.WriteLine(" Selected Range of cells(GridDataBoundGrid)are in Clipboard. This is" + val);
MessageBox.Show("Data copied");

VB

'To copy selected ranges in grid control.
Dim val As Boolean = Me.gridControl1.CutPaste.CopyTextToClipboard(Me.gridControl1.Selections.Ranges)
Console.WriteLine(" Selected Range of cells(GridControl)are in Clipboard. This is" & val)
MessageBox.Show("Data copied")
'To copy selected range of cells to clipboard in GridDataBoundGrid.
Dim val As Boolean = Me.gridDataBoundGrid1.Model.CutPaste.CopyTextToClipboard(Me.gridDataBoundGrid1.Selections.Ranges)
Console.WriteLine(" Selected Range of cells(GridDataBoundGrid)are in Clipboard. This is" & val)
MessageBox.Show("Data copied")

Refer to the following screenshot.

Copy the selected range of cells

Figure 1: Copy the selected range of cells

Samples:

C#: CopySelectedRanges

VB: CopySelectedRanges

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied