private void button1_Click(object sender, EventArgs e)
{
richTextBox1.AppendText(\"\\r\\n\");
richTextBox1.Focus();
string s = \"Enter \";
richTextBo
Simplest way i prefer is,
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.Text = DateTime.Now.ToString() + richTextBox1.Text;
}
It will prepend Current DateTime at Start.
Technically if you're inserting it at the top of the text, you're "inserting" or "prepending", not "appending". ;)
You can use the SelectedText property to insert text at the start of a RichTextBox. I just knocked up a quick demo app to test it out:
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength = 0;
richTextBox1.SelectedText = DateTime.Now.ToString();
}
That inserts the current time at the start of the RichTextBox when button1 is clicked.
previous messages seems obsolete. I solve it by :
Paragraph newExternalParagraph = new Paragraph();
newExternalParagraph.Inlines.Add( new Bold(new Run("[" + hour.ToString() + ":" + minute.ToString() + "]"))
{
Foreground = Brushes.Yellow
});
_consoleText.Document.Blocks.InsertBefore(_consoleText.Document.Blocks.FirstBlock , newExternalParagraph);