C#:如何将包含新行到文本框字符串? [英] C#: how to insert string containing new lines into TextBox?

查看:145
本文介绍了C#:如何将包含新行到文本框字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么插入包含新行到一个TextBox字符串?

How do you insert a string containing new lines into a TextBox?

在我这做使用 \\\
作为新行字符,这是行不通的。

When I do this using \n as the new line character, it doesn't work.

推荐答案

您必须将文本框的多行属性设置为真实,你可以使用

You have to set the multiline property of the textbox to true and you can use

Environment.NewLine

作为新行字符。

您也可以使用,而不是Environment.NewLine \r\\\

You can also use \r\n instead of Environment.NewLine

TextBox1.Text = "First line\r\nSecond line"

这篇关于C#:如何将包含新行到文本框字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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