다음을 통해 공유


RichTextBox.Selection 속성

정의

TextSelection 의 현재 선택을 포함하는 RichTextBox개체를 가져옵니다.

public:
 property System::Windows::Documents::TextSelection ^ Selection { System::Windows::Documents::TextSelection ^ get(); };
public System.Windows.Documents.TextSelection Selection { get; }
member this.Selection : System.Windows.Documents.TextSelection
Public ReadOnly Property Selection As TextSelection

속성 값

TextSelection

TextSelection 의 현재 선택을 포함하는 RichTextBox개체입니다.

반환된 기본 TextSelectionIsEmpty 속성 값 true가 있습니다. 빈 TextSelection 은 선택 영역이 없는 텍스트 영역에 캐럿으로 렌더링됩니다.

예제

다음 예제에서는이 속성의 사용을 보여 줍니다.

// Create a simple FlowDocument to serve as the content input for the construtor.
FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("Simple FlowDocument")));
// After this constructor is called, the new RichTextBox rtb will contain flowDoc.
RichTextBox rtb = new RichTextBox(flowDoc);
// This call will select the entire contents of the RichTextBox.
rtb.SelectAll();
// This call returns the current selection (which happens to be the entire contents
// of the RichTextBox) as a TextSelection object.
TextSelection currentSelection = rtb.Selection;
' Create a simple FlowDocument to serve as the content input for the construtor.
Dim flowDoc As New FlowDocument(New Paragraph(New Run("Simple FlowDocument")))
' After this constructor is called, the new RichTextBox rtb will contain flowDoc.
Dim rtb As New RichTextBox(flowDoc)
' This call will select the entire contents of the RichTextBox.
rtb.SelectAll()
' This call returns the current selection (which happens to be the entire contents
' of the RichTextBox) as a TextSelection object.
Dim currentSelection As TextSelection = rtb.Selection

설명

이 메서드를 Select 사용하여 프로그래밍 방식으로 콘텐츠를 선택합니다.

적용 대상