Articles in this section
Category / Section

How to programmatically copy a selection to the clipboard in WinForms GridControl?

1 min read

Clipboard operation

You can copy the range of cells that are already selected in the Grid by using CutPaste.Copy() method.

C#

//To copy the selected range
this.gridControl1.CutPaste.Copy();

 

VB

'To copy the selected range
Me.gridControl1.CutPaste.Copy()

 

When you want to copy the cells that are not in the selection of the Grid, use the CutPaste.CopyCellsToClipboard or CutPaste.CopyTextToClipboard methods depending upon whether you want to copy the styles or only the text to the clipboard.

C#

//To copy a particular range
GridRangeInfo gi = GridRangeInfo.Cells(2, 2, 4, 5);
GridRangeInfoList list = new GridRangeInfoList();
list.Add(gi);
this.gridControl1.CutPaste.CopyTextToClipboard(list);

 

VB

'To copy a particular range
Dim gi As GridRangeInfo = GridRangeInfo.Cells(2, 2, 4, 5)
Dim list As New GridRangeInfoList()
list.Add(gi)
Me.gridControl1.CutPaste.CopyTextToClipboard(list)

 

The following screenshot displays the Grid with CutPaste.CopyCellsToClipboard or CutPaste.CopyTextToClipboard methods.

Copy the selection to clipboard

Figure 1: Copy the selection to clipboard

Samples:

C#: Programatically Copy the Selection

VB: Programatically Copy the Selection

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