RichTextBox.Document Egenskap

Definition

Hämtar eller anger FlowDocument som representerar innehållet i 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

Egenskapsvärde

Ett FlowDocument objekt som representerar innehållet i RichTextBox.

Som standard är den här egenskapen inställd på en tom FlowDocument. Mer specifikt innehåller det tomma FlowDocument en enda Paragraph, som innehåller en enda Run som inte innehåller någon text.

Undantag

Ett försök görs att ange den här egenskapen till null.

Ett försök görs att ange den här egenskapen till en FlowDocument som representerar innehållet i en annan RichTextBox.

Den här egenskapen anges när ett ändringsblock har aktiverats.

Exempel

I följande exempel visas användningen av den här egenskapen.

// 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

Kommentarer

Ett FlowDocument får bara hanteras av en enda RichTextBox. Det går inte att ange ett enda FlowDocument som innehållet i flera RichTextBox kontroller.

Gäller för