EditPoint2.LessThan 方法
傳回被呼叫 EditPoint 物件的 AbsoluteCharOffset 值是否小於指定 TextPoint 物件的值。
命名空間: EnvDTE80
組件: EnvDTE80 (在 EnvDTE80.dll 中)
語法
'宣告
Function LessThan ( _
Point As TextPoint _
) As Boolean
bool LessThan(
TextPoint Point
)
bool LessThan(
[InAttribute] TextPoint^ Point
)
abstract LessThan :
Point:TextPoint -> bool
function LessThan(
Point : TextPoint
) : boolean
參數
Point
類型:TextPoint必要項。 要與呼叫點物件作比較的 TextPoint。
傳回值
類型:Boolean
如果相較之下 Point 的 AbsoluteCharOffset 屬性值大於呼叫點物件的 AbsoluteCharOffset 屬性值,則為 true,否則為 false。
備註
如果 Point 與呼叫點物件不在相同的文件中,LessThan 就會擲回 ArgumentException。 如果引數是 VirtualPoint,LessThan 會與 VirtualPoint 物件比較虛擬位置。 否則在其他情況下,它會比較實體位置。
範例
Sub LessThanExample(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
void LessThanExample(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.");
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。