WPF DataGrid, Copy to Clipboard after Ctrl+C,OnCopyingRowClipboardContent

前端 未结 2 1522
走了就别回头了
走了就别回头了 2021-02-13 05:27

For WPF, Data Grid I am trying to copy to clipboard my custom text data, after Ctrl+C Diverse attempts to use override OnCopyingRowClipboardContent(DataGridRo

2条回答
  •  眼角桃花
    2021-02-13 06:19

    You need to set the ClipboardRowContent property of DataGridRowClipboardEventArgs

    static void dataGrid_CopyingRowClipboardContent(object sender, DataGridRowClipboardEventArgs e)
    {
        e.ClipboardRowContent.Clear();
        e.ClipboardRowContent.Add(new DataGridClipboardCellContent(e.Item, (sender as DataGrid).Columns[0], "Abc-hello"));
    }
    

提交回复
热议问题