wpf datagrid 复制并粘贴您所看到的内容

发布于 2024-11-27 15:34:13 字数 225 浏览 0 评论 0原文

我在wpf中使用数据网格,它默认具有复制和粘贴功能。

我有一个日期时间列,我使用绑定和字符串格式使其以我想要的日期时间格式显示。

但是,当我复制并粘贴时,粘贴的文本变成未格式化的日期时间。

有没有办法复制粘贴“所见即所得”?

谢谢,Kev

编辑:我尝试使用 ClipboardContentBinding,将与我在绑定中所做的相同的内容放入其中。但这没有用

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 pasted 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

祁梦 2024-12-04 15:34:13

DataGrid 有许多剪贴板扩展点,您可以连接到其中并查看发生了什么。网格本身有一个 CopyingRowClipboardContent 事件,除了在事件参数中包含所有需要的信息之外,还有一个很好的帮助方法 FormatClipboardCellValues(string format)。此外,每列都有一个CopyingCellClipboardContent,可用于满足您特定的数据时间列需求。

注意:默认情况下,如果未明确指定,DataGrid 的绑定列(从 DataGridBoundColumn 派生的列)将使 ClipboardContentBinding 指向 Binding 属性。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文