Articles in this section
Category / Section

How to capture the clipboard events of WPF SpreadSheet

1 min read

Capture the clipboard operations using the PreviewKeyDown event in the SfSpreadsheet control, in which the copy/paste could be captured using the keyboard shortcuts.

C#

protected override void OnAttached()
{
    //Event Subscription
    this.AssociatedObject.PreviewKeyDown += AssociatedObject_PreviewKeyDown;
}
 
//Event Customization
private void AssociatedObject_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
    //To capture the clipboard(copy/paste) opeartions  
    if ((Keyboard.IsKeyDown(Key.LeftCtrl)) && e.Key == Key.C)
    {
        MessageBox.Show("Control+C Pressed");
    }
    else if ((Keyboard.IsKeyDown(Key.LeftCtrl)) && e.Key == Key.V)
    {
        MessageBox.Show("Control+V Pressed");
    }
}

View sample in GitHub

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied