Comment obtenir le texte au format RTF d'un RichTextBox
? J'essaie d'obtenir comme ça, mais la propriété n'existe pas.Comment obtenir le RTF de RichTextBox
RichTextBox rtb = new RichTextBox();
string s = rtb.Rtf;
Comment obtenir le texte au format RTF d'un RichTextBox
? J'essaie d'obtenir comme ça, mais la propriété n'existe pas.Comment obtenir le RTF de RichTextBox
RichTextBox rtb = new RichTextBox();
string s = rtb.Rtf;
Pour obtenir le XAML réel créé par l'utilisateur à l'intérieur de la RichTextBox:
TextRange tr = new TextRange(myRichTextBox.Document.ContentStart,
myRichTextBox.Document.ContentEnd);
MemoryStream ms = new MemoryStream();
tr.Save(ms, DataFormats.Xaml);
string xamlText = ASCIIEncoding.Default.GetString(ms.ToArray());
EDIT: Je n'ai pas le code devant moi pour tester, mais une instance du type TextRange
a une méthode Save
(pour écouter) qui prend un paramètre DataFormats
, qui peut être DataFormats.Rtf
Il y a 2 classes de RichTextBox, l'un du cadre winforms et l'autre du cadre WPF:Seul le WinTools RichTextBox a une propriété Rtf, l'autre possède une propriété Document qui contient un FlowDocument.
DataFormats contient un membre Rtf. Peut-être que cette méthode fonctionnera. –
Et maintenant, comment puis-je définir le texte RTF d'un RichTextBox? – rpf
poser une autre question! ;) –