richtextbox newbie question
-
hi all ! i'm pretty newbie in the coding world and have a little problem that i cant find a solution i have 2 richtextbox. the first is to write the text and the second to see it (read only) so there is my code
private void button2_Click_1(object sender, EventArgs e) { DateTime dt = DateTime.Now; string str1 = dt.ToString("H:mm:ss").PadRight(10); string str2 = richTextBox1.Text; string str3 = str1 + str2 + "\n"; richTextBox2.AppendText(str3); richTextBox1.Clear();
the real goal is simple, i want the time to be wrote at the start of every text add. Thats why i made it like that. My problem is the "\n" at the end of the string 3. If i dont put it, then the next text is wrote a the end of the first one. If i put it and the user finish is text and press enter then the click button, i have a empty line (witch i dont want it). The richtextbox2 gonna be print at the end and its a report to be showed to the boss as a clean copy so empty lines need to be removed. if someone can help me btw, sorry for my english, i know i'm bad but what can i say ? i'm talking in english like in coding :laugh: thanks ;) -
hi all ! i'm pretty newbie in the coding world and have a little problem that i cant find a solution i have 2 richtextbox. the first is to write the text and the second to see it (read only) so there is my code
private void button2_Click_1(object sender, EventArgs e) { DateTime dt = DateTime.Now; string str1 = dt.ToString("H:mm:ss").PadRight(10); string str2 = richTextBox1.Text; string str3 = str1 + str2 + "\n"; richTextBox2.AppendText(str3); richTextBox1.Clear();
the real goal is simple, i want the time to be wrote at the start of every text add. Thats why i made it like that. My problem is the "\n" at the end of the string 3. If i dont put it, then the next text is wrote a the end of the first one. If i put it and the user finish is text and press enter then the click button, i have a empty line (witch i dont want it). The richtextbox2 gonna be print at the end and its a report to be showed to the boss as a clean copy so empty lines need to be removed. if someone can help me btw, sorry for my english, i know i'm bad but what can i say ? i'm talking in english like in coding :laugh: thanks ;) -
Um, have you tried this?
DateTime dt = DateTime.Now; this.richTextBox1.SelectedText = dt.ToString("H:mm:ss").PadRight(10);