Quantcast
Viewing latest article 26
Browse Latest Browse All 40

what is best way to sort lines in RichTextBox

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);}
  1. Is there an best way to do this?

  2. 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.


Viewing latest article 26
Browse Latest Browse All 40

Trending Articles