Articles in this section
Category / Section

Copy selected records to clipboard in WinForms GridGroupingControl.

1 min read

Clipboard operation

To copy the selected record, use the ClipboardCopy event in WinForms GridGroupingControl. The selected row can be obtained by using the CurrentRecord property. The record values can be obtained by using the GetValue method. The retrieved data can be stored in the clipboard using the SetDataObject method.

 

Code snippet

 

C#

this.gridGroupingControl1.TableModel.ClipboardCopy += TableModel_ClipboardCopy;
private Record copiedRecord;
void TableModel_ClipboardCopy(object sender, GridCutPasteEventArgs e)
{
    String value=string.Empty;
    copiedRecord = this.gridGroupingControl1.Table.CurrentRecord;
    foreach (GridVisibleColumnDescriptor column in this.gridGroupingControl1.TableDescriptor.VisibleColumns)
    {
        value += copiedRecord.GetValue(column.Name).ToString()+"\t";
    }
    Clipboard.SetDataObject(new DataObject(value),true);
    e.Handled = true;
}

 

VB

Private Me.gridGroupingControl1.TableModel.ClipboardCopy += AddressOf TableModel_ClipboardCopy
Private copiedRecord As Record
Private Sub TableModel_ClipboardCopy(ByVal sender As Object, ByVal e As GridCutPasteEventArgs)
      Dim value As String=String.Empty
      copiedRecord = Me.gridGroupingControl1.Table.CurrentRecord
      For Each column As GridVisibleColumnDescriptor In Me.gridGroupingControl1.TableDescriptor.VisibleColumns
            value &= copiedRecord.GetValue(column.Name).ToString()+Constants.vbTab
 Next column
      Clipboard.SetDataObject(New DataObject(value),True)
      e.Handled = True
End Sub

 

 

 

Sample links:

C#: Copy_Paste

VB: Copy_Paste

Reference link: https://help.syncfusion.com/windowsforms/classic/gridgroupingcontrol/clipboard-operations


Conclusion

I hope you enjoyed learning about how to Copy selected records to clipboard in WinForms GridGroupingControl.

You can refer to our WinForms GridControl feature tour page to learn about its other groundbreaking feature representations. You can also explore our WinForms GridControl documentation to understand how to create and manipulate data.

For current customers, you can check out our 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 other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

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