Copy selected records to clipboard in WinForms GridGroupingControl.
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.
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;
}AddHandler 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() & vbTab
Next
Clipboard.SetDataObject(New DataObject(value),True)
e.Handled = True
End SubSample Links:
C#: Copy_Paste
VB: Copy_Paste
Reference Link: Clipboard Operations
Conclusion
I hope you enjoyed learning about how to Copy selected records to clipboard in GridGroupingControl.
You can refer to our WinForms GridGroupingControl feature tour page to learn about its other groundbreaking feature representations. You can also explore our WinForms GridGroupingControl 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 forums, Direct-Trac, or feedback portal. We are always happy to assist you!