다음을 통해 공유


EditPoint.GreaterThan(TextPoint) Method

Definition

Returns whether the value of the EditPoint object's AbsoluteCharOffset property is greater than that of the given TextPoint object.

public:
 bool GreaterThan(EnvDTE::TextPoint ^ Point);
public:
 bool GreaterThan(EnvDTE::TextPoint ^ Point);
bool GreaterThan(EnvDTE::TextPoint const & Point);
[System.Runtime.InteropServices.DispId(33)]
public bool GreaterThan (EnvDTE.TextPoint Point);
[<System.Runtime.InteropServices.DispId(33)>]
abstract member GreaterThan : EnvDTE.TextPoint -> bool
Public Function GreaterThan (Point As TextPoint) As Boolean

Parameters

Point
TextPoint

Required. A TextPoint to compare to the calling point object.

Returns

true if Point has a smaller AbsoluteCharOffset property value compared to the calling EditPoint object's AbsoluteCharOffset property; otherwise, false.

Implements

Attributes

Examples

Sub GreaterThanExample(ByVal dte As DTE)  

    ' Create a new text file.  
    dte.ItemOperations.NewFile()  
    Dim txtDoc As TextDocument = _  
        CType(dte.ActiveDocument.Object(), TextDocument)  

    ' Create an edit point at the empty text document's StartPoint   
    ' and EndPoint; CompareEditPoints displays "point1 and point2  
    ' occupy the same location."  
    Dim point1 As EditPoint = txtDoc.StartPoint.CreateEditPoint()  
    Dim point2 As EditPoint = txtDoc.EndPoint.CreateEditPoint()  
    CompareEditPoints(point1, point2)  

    ' Insert ten lines of text.  
    Dim i As Integer  
    For i = 1 To 10  
        point1.Insert("Line " & i.ToString() & vbCrLf)  
    Next  

    ' Create an edit point at the text document's StartPoint and   
    ' EndPoint; CompareEditPoints displays "point1 comes before point2."  
    point1 = txtDoc.StartPoint.CreateEditPoint()  
    point2 = txtDoc.EndPoint.CreateEditPoint()  
    CompareEditPoints(point1, point2)  

End Sub  

Sub CompareEditPoints(ByVal point1 As EditPoint, _  
    ByVal point2 As EditPoint)  

    If point1.LessThan(point2) Then  
        MsgBox("point1 comes before point2.")  
    ElseIf point1.GreaterThan(point2) Then  
        MsgBox("point2 comes before point1.")  
    ElseIf (point1.EqualTo(point2)) Then  
        MsgBox("point1 and point2 occupy the same location.")  
    End If  

End Sub  
public void GreaterThanExample(DTE dte)  
{  
    // Create a new text file.  
    dte.ItemOperations.NewFile(@"General\Text File", "",   
        Constants.vsViewKindPrimary);  
    TextDocument txtDoc =   
        (TextDocument)dte.ActiveDocument.Object("");  

    // Create an edit point at the empty text document's StartPoint   
    // and EndPoint; CompareEditPoints displays "point1 and point2  
    // occupy the same location."  
    EditPoint point1 = txtDoc.StartPoint.CreateEditPoint();  
    EditPoint point2 = txtDoc.EndPoint.CreateEditPoint();  
    CompareEditPoints(point1, point2);  

    // Insert ten lines of text.  
    for (int i = 1; i <= 10; i++)  
    {  
        point1.Insert("Line " + i.ToString() + Environment.NewLine);  
    }  

    // Create an edit point at the text document's StartPoint and   
    // EndPoint; CompareEditPoints displays "point1 comes before point2."  
    point1 = txtDoc.StartPoint.CreateEditPoint();  
    point2 = txtDoc.EndPoint.CreateEditPoint();  
    CompareEditPoints(point1, point2);  
}  

void CompareEditPoints(EditPoint point1, EditPoint point2)  
{  
    if (point1.LessThan(point2))  
        MessageBox.Show("point1 comes before point2.");  
    else if (point1.GreaterThan(point2))  
        MessageBox.Show("point2 comes before point1.");  
    else if (point1.EqualTo(point2))  
        MessageBox.Show("point1 and point2 occupy the same location.");  
}  

Remarks

GreaterThan throws a ArgumentException exception if Point is not in the same document as the calling point object. With the VirtualPoint, GreaterThan compares the virtual positions if the argument is a VirtualPoint. Otherwise, it compares the "physical" positions.

Applies to