How to disable clipboard Cut, Copy, or Paste in a Grid
15 Jun 20211 minute to read
If you want to conditionally disable support, handle ClipboardCanCut, ClipboardCanCopy, or ClipboardCanPaste events and cancel the events by setting e.Handled to True and e.Result to False under the desired conditions.
To completely turn off support, set this property.
//Completely turns off Clipboard cut, copy, or paste.
this.grid.CutPaste.ClipboardFlags = GridDragDropFlags.Disabled;
'Completely turns off Clipboard cut, copy, or paste.
Me.grid.CutPaste.ClipboardFlags = GridDragDropFlags.Disabled
Here are some code samples.
//Subscribes to the event.
this.gridControl1.ClipboardCanPaste += new GridCutPasteEventHandler(this.gridControl1_ClipboardCanPaste);
//Handles ClipBoardCanPaste event to disable Paste operation.
private void gridControl1_ClipboardCanPaste(object sender, GridCutPasteEventArgs e)
{
if(someCondition)
{
e.Handled = true;
//Sets Result Property to False to disable the process.
e.Result = false;
}
}
'Handles ClipBoardCanPaste event to disable Paste operation.
Private Sub gridControl1_ClipboardCanPaste(sender As Object, _e As GridCutPasteEventArgs) _Handles GridControl1.ClipboardCanPaste
If someCondition Then
e.Handled = True
'Sets Result Property to False to disable the process.
e.Result = False
End If
'GridControl1_ClipboardCanPaste.
End Sub