Reputation: 1286
I've got a RichTextBox containing lines of text (each line a paragraph), and I have a line number that represents an error. I want to set the caret to be at the start of that line. How?
Upvotes: 0
Views: 399
Reputation: 8204
I haven't got a working installation of C# on my machine at the moment, but from looking at the docs it seems you should be able to first locate the paragraph you want (probably by enumerating through them, there does not seem to be an index function) in yourFlowDocument.Blocks
and then:
TextPointer paragraphStart = paragraph.ElementStart;
richTextBox.CaretPosition = paragraphStart;
Upvotes: 2