We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to copy the selected records to the clipboard in WinForms GridGroupingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: September 26, 2018 |
Last Revised Date: December 23, 2019

Clipboard operation

To copy the selected record, use the ClipboardCopy event. 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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile