RichTextBox.Document Propriété

Définition

Obtient ou définit le FlowDocument qui représente le contenu de la RichTextBox.

public:
 property System::Windows::Documents::FlowDocument ^ Document { System::Windows::Documents::FlowDocument ^ get(); void set(System::Windows::Documents::FlowDocument ^ value); };
public System.Windows.Documents.FlowDocument Document { get; set; }
member this.Document : System.Windows.Documents.FlowDocument with get, set
Public Property Document As FlowDocument

Valeur de propriété

FlowDocument

Objet FlowDocument qui représente le contenu de la RichTextBox.

Par défaut, un FlowDocument vide est affecté à cette propriété. Le FlowDocument vide contient un Paragraph unique contenant un unique Run qui ne contient pas de texte.

Exceptions

Une tentative d'affecter null à cette propriété est effectuée.

Une tentative est effectuée pour affecter à cette propriété un FlowDocument qui représente le contenu d'une autre RichTextBox.

Cette propriété est définie lorsqu'un bloc de modifications a été activé.

Exemples

L’exemple suivant illustre l’utilisation de cette propriété.

// Create a simple FlowDocument to serve as content.
FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("Simple FlowDocument")));
// Create an empty, default RichTextBox.
RichTextBox rtb = new RichTextBox();
// This call sets the contents of the RichTextBox to the specified FlowDocument.
rtb.Document = flowDoc;
// This call gets a FlowDocument representing the contents of the RichTextBox.
FlowDocument rtbContents = rtb.Document;
' Create a simple FlowDocument to serve as content.
Dim flowDoc As New FlowDocument(New Paragraph(New Run("Simple FlowDocument")))
' Create an empty, default RichTextBox.
Dim rtb As New RichTextBox()
' This call sets the contents of the RichTextBox to the specified FlowDocument.
rtb.Document = flowDoc
' This call gets a FlowDocument representing the contents of the RichTextBox.
Dim rtbContents As FlowDocument = rtb.Document

Remarques

Un FlowDocument peut uniquement être hébergé par un seul RichTextBox. La spécification d’un seul FlowDocument comme contenu de plusieurs RichTextBox contrôles n’est pas prise en charge.

S’applique à