Quantcast
Channel: User Jack - Stack Overflow
Viewing all articles
Browse latest Browse all 40

what is best way to sort lines in RichTextBox

$
0
0

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 all articles
Browse latest Browse all 40

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>