Private Sub Model_ClipboardCanCopy(ByVal sender As Object, ByVal e As GridCutPasteEventArgs)
Dim RowIndex = GridGroupingControl1.Table.CurrentRecord.GetRowIndex
Dim str As String = Nothing
For Each descriptor As FieldDescriptor In Me.GridGroupingControl1.TableDescriptor.Fields
str &= Me.GridGroupingControl1.Table.Records(RowIndex).GetValue(descriptor).ToString() & Constants.vbTab
Next descriptor
Clipboard.SetText(str)
GridGroupingControl1.TableModel.CutPaste.Copy()
End Sub
Additionally, I would like to know if a paste can be performed in the AddNew row?
Thank you in advance!- Nicolas
I try to perform a clipboard copy / paste operation in a GGC, for a single record. The copy seems to get in (let me know if there is any better), but it seems I can paste only the first cell. |
Solution 1
The reported scenario can be achieved by using Clipboard.SetDataObject method as of follows. Please refer the below mentioned code snippet.
Code snippet:
Private Sub TableModel_ClipboardCopy(ByVal sender As Object, ByVal e As GridCutPasteEventArgs)
Dim rowindex As Integer = Me.gridGroupingControl1.Table.CurrentRecord.GetSourceIndex()
copiedrecord = Me.gridGroupingControl1.Table.Records(rowindex)
value = String.Empty
For Each column As GridVisibleColumnDescriptor In Me.gridGroupingControl1.TableDescriptor.VisibleColumns
value += Me.gridGroupingControl1.Table.Records(rowindex).GetValue(column.Name).ToString() & Constants.vbTab
Next column
Clipboard.SetDataObject(New DataObject(value), True)
End Sub
|
Solution 2
This can be achieved by using Record.GetValue and Record.SetValue method in ClipboardCopy and ClipboardPaste event. Please refer the below code snippet,
Code snippet:
Private copiedrecord As Record
Private Sub TableModel_ClipboardCopy(ByVal sender As Object, ByVal e As GridCutPasteEventArgs)
Dim rowindex As Integer = Me.gridGroupingControl1.Table.CurrentRecord.GetSourceIndex()
copiedrecord = Me.gridGroupingControl1.Table.Records(rowindex)
End Sub
Private Sub TableModel_ClipboardPaste(ByVal sender As Object, ByVal e As GridCutPasteEventArgs)
e.Handled = true;
For Each column As GridVisibleColumnDescriptor In Me.gridGroupingControl1.TableDescriptor.VisibleColumns
Dim Copiedvalue As String = copiedrecord.GetValue(column.Name).ToString()
Me.gridGroupingControl1.Table.CurrentRecord.SetValue(column.Name, Copiedvalue)
Next column
End Sub
| |
Additionally, I would like to know if a paste can be performed in the AddNew row?
|
Yes. You can paste the copied values in AddNew row also. Please refer the below attached sample. |