C #: How to add a line to a note?

I have a RichBox (memo) in which I would like to add lines.

I am currently using this

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

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

Memo.Lines.add('The line I''d like to add');
+3
source share
3 answers

AppendText is the closest to it. Unfortunately, you still need to add a newline:

RichBox1.AppendText( "the line I'd like to add" + Environment.NewLine );
+8
source

You can use the extension method to add this convenient method addto 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';
    }
}
+4
source

You can use the AppendText method from TextBoxBase and explicitly add a new line

RichBox1.AppendText("the line i'd like to add" + Environment.NewLine);
+2
source

Source: https://habr.com/ru/post/1706589/


All Articles