Re: WPF RichTextBox взять первые 20000 символов
От: vaa  
Дата: 29.12.22 01:10
Оценка:
Здравствуйте, dsalodki, Вы писали:

D>Как в RichTextBox взять первые n символов, учитывая что может быть форматирование текста


string StringFromRichTextBox(RichTextBox rtb)
{
    TextRange textRange = new TextRange(
        // TextPointer to the start of content in the RichTextBox.
        rtb.Document.ContentStart,
        // TextPointer to the end of content in the RichTextBox.
        rtb.Document.ContentEnd
    );

    // The Text property on a TextRange object returns a string
    // representing the plain text content of the TextRange.
    return textRange.Text;
}
☭ ✊ В мире нет ничего, кроме движущейся материи.
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.