共用方式為


RichTextBox.Document 屬性

定義

取得或設定 FlowDocument,表示 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

屬性值

FlowDocument

FlowDocument 物件,表示 RichTextBox 的內容。

根據預設,這個屬性會設定為空的 FlowDocument。 更明確地說,空的 FlowDocument 內含一個 Paragraph,其中包含一個 Run,並且未內含文字。

例外狀況

嘗試將這個屬性設定為 null

嘗試將這個屬性設定為 FlowDocument,表示另一個 RichTextBox 的內容。

當啟動變更區塊時,便會這定這個屬性。

範例

下列範例說明如何使用這個屬性。

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

備註

FlowDocument 只能由單 RichTextBox 一 裝載。 不支援將單一 FlowDocument 指定為多個 RichTextBox 控制項的內容。

適用於