C# Wpf DataGrid copy makes Application go in Break Mode

0

I'm new to C# and WPF, i'm using a WPF Datagrid in my Application and on my Work Computer whenever i select some cells and press ctrl + c to copy their content it makes the application go into break mode.

The error i'm getting is

Blockquote System.Runtime.InteropServices.COMException: 'OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))'

This happens whenever i try to do it in the laptop i use at work, however i tried it on my home pc and it works alright, i can copy and then paste the cells's content into excel no problem

Do any of you guys know how to fix this?

Thanks in advance

c#
wpf
asked on Stack Overflow Jun 4, 2018 by Darthmw

1 Answer

0

Try using CopyingRowClipboardContent event of the DataGrid and within the handler use Clipboard.SetDataObject() method. You might have to set the SelectionUnit property of the DataGrid to "FullRow"

answered on Stack Overflow Jun 4, 2018 by Dean Kuga

User contributions licensed under CC BY-SA 3.0