tags:

views:

463

answers:

3

Hello,

I have a RichBox(memo) that I'd like to add lines to.

Currently,I use this

RichBox1.text += "the line I'd like to add" + "\n";

Isn't there something like the method in Delphi below?

Memo.Lines.add('The line I''d like to add');
+6  A: 

AppendText is the closest it gets. Unfortunately you still have to append the newline character:

RichBox1.AppendText( "the line I'd like to add" + Environment.NewLine );
Chris Pebble
+1  A: 

You can use the AppendText method from TextBoxBaseand explicitly add the new line

RichBox1.AppendText("the line i'd like to add" + Environment.NewLine);
JaredPar
+3  A: 

You could use an extension method to add this handy add method to the RichTextBox class. 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';
    }
}
Andrew Garrison