Здравствуйте, vaa, Вы писали:
vaa>Здравствуйте, dsalodki, Вы писали:
D>>Как в RichTextBox взять первые n символов, учитывая что может быть форматирование текста
vaa>vaa>string StringFromRichTextBox(RichTextBox rtb)
vaa>{
vaa> TextRange textRange = new TextRange(
vaa> // TextPointer to the start of content in the RichTextBox.
vaa> rtb.Document.ContentStart,
vaa> // TextPointer to the end of content in the RichTextBox.
vaa> rtb.Document.ContentEnd
vaa> );
vaa> // The Text property on a TextRange object returns a string
vaa> // representing the plain text content of the TextRange.
vaa> return textRange.Text;
vaa>}
vaa>
не совсем то что нужно, там могут быть непечатные символы, но решение нашёл в интернете
https://stackoverflow.com/questions/1454440/select-range-of-text-in-wpf-richtextbox-flowdocument-programmatically
подскажи пожалуйста как из TextRange задать форматированный текст у RichTextBox