c# - 如何将具有 CR\LF 的字符串变量设置到 Winform 文本框中?
问题描述
我有一个 Winforms 文本框设置为 AcceptReturns = true,Scrollbars = vertical,Multiline = true。我通过循环遍历数据表来构造一个名为 note 的字符串,将值放入 note 中:note = note 加上“\n\n”。当我使用文本可视化工具查看字符串时,它正确显示了 CR\LF,但在命令之后:remarks.text = note,文本框没有 CR\LF。如何让 CR\LF 得到尊重?
int x = 0;
string note = "";
command = null;
DataTable dtnew = new DataTable();
foreach (string rcd in app.feecd) // app.feecd is an array established earlier in code
{
command = GetConnectedClass.newsqlconnection("SELECT NoteDesc from dbo.inspnote where NoteCode = @selcode");
command.Parameters.AddWithValue("@selcode", rcd);
dtnew.Load(command.ExecuteReader());
note = note + dtnew.Rows[x].Field<string>("NoteDesc") + "\n\n";
command = null;
x = x + 1;
}
if (remarks.Text == "")
{ remarks.Text = note; } // note has CR\LF but remarks.Text NO CR\LF ????
else { remarks.Text = remarks.Text + "\n\n" + note; }
解决方案
推荐阅读
- c# - 如何将 Unity C# 结构发送到 Objective-C 插件?
- javascript - 如何正确使用 intl.formatRelativeTime()
- node.js - MognoDB Nodejs 通过 ID 获取特定的集合文档
- rust - 是否可以等待 &dyn Future?
- ios - 如何从 iOS 14 中的 UIDocumentPickerViewController 获取文件名和文件大小?
- python - 求解输入代数方程python
- python - 将“文件”类型的文件读入熊猫数据框的最简单方法
- node.js - $limit 和 $skip 在 MongoDB 聚合管道中是可选的
- ios - 安装反应原生矢量图标后构建问题
- python - Python烧瓶应用程序,它返回文件列表