다음을 통해 공유


RichTextBox.ContentStart Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets a TextPointer that indicates the start of content in the RichTextBox.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public ReadOnly Property ContentStart As TextPointer
public TextPointer ContentStart { get; }

Property Value

Type: System.Windows.Documents.TextPointer
A TextPointer that indicates the start of content in the RichTextBox.

Remarks

In a completely empty RichTextBox (one without blocks), ContentEnd is the same as ContentStart, and both are insertion positions. This is the only instance when ContentStart or ContentEnd is an insertion position.

Examples

The following method uses the ContentStart and ContentEnd methods to determine if a RichTextBox is empty.

    'This method returns true if the RichTextBox is empty.
    Public Function isRichTextBoxEmpty() As Boolean
        Dim startPointer As TextPointer = MyRTB1.ContentStart.GetNextInsertionPosition(LogicalDirection.Forward)
        Dim endPointer As TextPointer = MyRTB1.ContentEnd.GetNextInsertionPosition(LogicalDirection.Backward)
        If (startPointer.CompareTo(endPointer) = 0) Then
            Return True
        Else
            Return False
        End If
    End Function

//This method returns true if the RichTextBox is empty.
public bool isRichTextBoxEmpty()
{
    TextPointer startPointer = MyRTB1.ContentStart.GetNextInsertionPosition(LogicalDirection.Forward);
    TextPointer endPointer = MyRTB1.ContentEnd.GetNextInsertionPosition(LogicalDirection.Backward);
    if (startPointer.CompareTo(endPointer) == 0)
        return true;
    else
        return false;
}

Version Information

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.