I'm looking for the best way to sort lines of RichTextBox, I'm using this at moment:
public void SortLines(object sender, EventArgs e){ TextPointer pStart = TextInput.Document.ContentStart; TextPointer pEnd = TextInput.Document.ContentEnd; TextRange text = new TextRange(pStart, pEnd); string[] lines = text.Text.Split('\n'); Array.Sort(lines); text.Text = String.Join(String.Empty, lines);}
Is there an best way to do this?
When I call it, the cursor is placed into first RichTextBox line, how do I to put it where it was before?I tried to set pStart/pEnd and CaretPositiom, but the properties are read only.
I hope this is clear. Thanks in advance.