数据网格上的CTRL-C - 如何在粘贴时删除换行符 [英] CTRL-C on datagrid - how to remove line feed when pasting

查看:103
本文介绍了数据网格上的CTRL-C - 如何在粘贴时删除换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从数据网格中复制(只读)单元格的默认行为似乎是包含最终换行符。然后用户需要在粘贴后删除换行符。我试图操纵剪贴板内容,没有运气。如何删除
换行符?

It appears that the default behavior for copying (read-only) cells from a datagrid is to include a final line feed. Users then need to delete the line feed after pasting. I've tried to manipulate the clipboard contents, with no luck. How can I remove the line feed?

private void DataGrid_OnCopyingRowClipboardContent(object sender, DataGridRowClipboardEventArgs e)
        {

e.ClipboardRowContent...?
}


从技术上讲,我只想要第一列数据,而且我能够实现这一点,但总有一个换行符。

Technically, I only want the first column data, and I'm able to achieve that, but there is always a line feed.

推荐答案

我不知道,你怎么样?复制并粘贴。

I don't know, how do you copy and paste.

但你可以 获取剪贴板数据并删除特定的 字符 如下所示。

But you can  get Clipboard Data with remove the specific  characters as below.

 string ClipboardData=((string)Clipboard.GetData(DataFormats.Text)).TrimEnd('\r', '\n');

然后你可以为剪贴板设置数据 如下所示,

Then you can set data for the Clipboard  as below,

Clipboard.SetData(DataFormats.Text, ClipboardData);

最好的问候,

Bob


这篇关于数据网格上的CTRL-C - 如何在粘贴时删除换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆