开发者

wpf datagrid copy and paste what you see

I am using data grid in wpf, and it has copy and paste by default.

I have a date time column and i used binding and String format to make it show it in the date time format i want.

However, when i copy and paste, the past开发者_如何学运维ed text becomes the unformatted date time.

Is there a way to do a copy a paste on "What you see is what you get?"

Thanks, Kev

Edit: I tried using ClipboardContentBinding, putting same thing as i did in binding. And that didn't work


DataGrid has a number of clipboard extensibility points you can hook into and see what is going on. The grid itself has a CopyingRowClipboardContent event that apart from having all the needed information in the event arguments has a nice helper method FormatClipboardCellValues(string format). Also each column has a CopyingCellClipboardContent which can be used for your particular data time column needs.

Note: By default DataGrid's bound columns (those deriving from DataGridBoundColumn) will have them ClipboardContentBinding pointing to the Binding property if not specified explicitly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜