How to copy the selected range of cells to the clipboard in WinForms GridControl and GridDataBoundGrid?
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.
Figure 1: Copy the selected range of cells
Samples:
Conclusion
I hope you enjoyed learning about How to copy the selected range of cells to the clipboard in WinForms GridControl and GridDataBoundGrid?
You can refer to our WinForms Grid feature tour page to know about its other groundbreaking feature representations. You can also explore our documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our ASP.NET MVC Chart and other ASP.NET MVC components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!