// get rid of any whitespace at the end richTextBox1.Text = richTextBox1.Text.TrimEnd(' ', '\r', '\n', '\t'); // find length of remaining text int length = richTextBox1.Text.Length; if (length > 0) { // get physical line number of last character int lastLine = richTextBox1.GetLineFromCharIndex(length - 1); // get character index of first character on that line int firstIndex = richTextBox1.GetFirstCharIndexFromLine(lastLine); // remove characters on last line richTextBox1.Text = richTextBox1.Text.Substring(0, firstIndex); }
1 answers
The following code should do it:
answered one year ago by:
17279
153
thank you