I am having some trouble with my custom RichTextBox control.
The RichTextBox does not seem to have any concept of a “Lines” collection. But I need to manage the text by line.
Is there a way to get AND update a line of text in a RichTextBox?
The exact scenario I am going for is to look at each line in the RichTextBox and, if the line has more than 60 chars, insert a Environment.NewLine after the 60th char.
Update:
I have found that you can GET a line with this code:
richTextBox.Document.ContentStart.GetLineStartPosition(lineNumber);
But I still have no way to UPDATE a line.
You simple need to iterate over the lines, check the length, if it’s longer than 60, add a new line character. Repeat for all the characters in the line, and return the result.
Below is an outline of the code
The above code is useful, if you are running the formatting once.