本文整理匯總了C#中System.Windows.Controls.RichTextBox類的典型用法代碼示例。如果您正苦於以下問題:C# RichTextBox類的具體用法?C# RichTextBox怎麽用?C# RichTextBox使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RichTextBox類屬於System.Windows.Controls命名空間,在下文中一共展示了RichTextBox類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RichTextBoxExample
//引入命名空間
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Documents;
namespace SDKSample
{
public partial class RichTextBoxExample : Page
{
public RichTextBoxExample()
{
StackPanel myStackPanel = new StackPanel();
// Create a FlowDocument to contain content for the RichTextBox.
FlowDocument myFlowDoc = new FlowDocument();
// Add paragraphs to the FlowDocument.
myFlowDoc.Blocks.Add(new Paragraph(new Run("Paragraph 1")));
myFlowDoc.Blocks.Add(new Paragraph(new Run("Paragraph 2")));
myFlowDoc.Blocks.Add(new Paragraph(new Run("Paragraph 3")));
RichTextBox myRichTextBox = new RichTextBox();
// Add initial content to the RichTextBox.
myRichTextBox.Document = myFlowDoc;
myStackPanel.Children.Add(myRichTextBox);
this.Content = myStackPanel;
}
}
}