我有一个RichBox(备忘录),我想添加行.
目前,我用这个
RichBox1.text += "the line I'd like to add" + "\n";
Run Code Online (Sandbox Code Playgroud)
下面是Delphi中的方法吗?
Memo.Lines.add('The line I''d like to add');
Run Code Online (Sandbox Code Playgroud)
它最接近的是AppendText.不幸的是,您仍然需要附加换行符:
RichBox1.AppendText( "the line I'd like to add" + Environment.NewLine );
Run Code Online (Sandbox Code Playgroud)
您可以使用扩展方法将此方便的add方法添加到RichTextBox类.
http://msdn.microsoft.com/en-us/library/bb383977.aspx
public static class Extension
{
public static void add(this System.Windows.Forms.RichTextBox richText, string line)
{
richText.Text += line + '\n';
}
}
Run Code Online (Sandbox Code Playgroud)