Creating a newline in rich text box

别等时光非礼了梦想. 提交于 2019-12-02 12:29:37

问题


I need help on creating a new line for my RichTextBox which I cant make work when using CheckBox.

It keeps overlapping instead of creating a newline of words.

Tried using the method of rtbdisplay.text = (display+envrionment.newline); example from my code:

if (rbtnSmall.Checked == true)
{
    rtbDisplay.Text = "displaytext".PadRight(20) + "size".PadRight(23) +
                      qty.ToString().PadRight(20) + StrongDummy;
}

回答1:


Use the RichTextBox.Text property or the RichtTextBox.AppendText method to append a string with a newline.

myRichTextBox.Text += Environment.NewLine + "My new line.";

// Or

myRichTextBox.AppendText( Environment.NewLine + "My new line." );



回答2:


You can use c# Environment.NewLine Property as described in http://msdn.microsoft.com/en-us/library/system.environment.newline%28v=vs.110%29.aspx. Or, the "old style" like @"\r\n".

Rgds,



来源:https://stackoverflow.com/questions/24532241/creating-a-newline-in-rich-text-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!