\ n不在richtext框中工作 [英] \n not working in richtext box
本文介绍了\ n不在richtext框中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
disp.Text + = done +\ n; //为什么这不会在richtext框中生成新行
disp.Text = disp.Text +\ n +(完成); //此行在richtext框中生成一个新行
解决方案
如果要将文本附加到富文本框,则应使用AppendText函数,如:
disp.AppendText(已完成);
disp.AppendText(Environment.NewLine);
参见 RichTextBox.AppendText [ ^ ]
和
Environment.NewLine [ ^ ]
是的,它是:在底部,它添加了一个新队。但是因为它是空白的,你无法看到它,或者说它存在,除非你将输入光标移动到RichTextBox的末尾。试试这个:
private void button1_Click ( object sender,EventArgs e)
{
richTextBox1.Text + = Hello + \ n ;
}
private void button2_Click( object sender,EventArgs e)
{
richTextBox1.Text + = \ n + Hello;
}你会看到我的意思。
你必须附加Environment.NewLine $ p $它应该适合你。
disp.Text += done + "\n";//Why is this not generating a new line in the richtext box
disp.Text = disp.Text + "\n" + (done);//This line is generating a new line in richtext box
解决方案
If you want to append text to a rich text box, you should use the AppendText function, like:
disp.AppendText(done); disp.AppendText(Environment.NewLine);
See RichTextBox.AppendText[^]
And
Environment.NewLine[^]
Yes, it is: right at the bottom, it adds a new line. But because it is blank, you can't see it, or tell it is there unless you move the input cursor to the end of the RichTextBox. Try this:
private void button1_Click(object sender, EventArgs e) { richTextBox1.Text += "Hello" + "\n"; } private void button2_Click(object sender, EventArgs e) { richTextBox1.Text += "\n" + "Hello"; }And you will see what I mean.
You have to append withEnvironment.NewLineit should work for you.
这篇关于\ n不在richtext框中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文