CodeDelegate2.GetStartPoint(vsCMPart) 方法

定义

返回一个 TextPoint 对象,该对象定义委托定义的开头。

EnvDTE::TextPoint GetStartPoint(EnvDTE::vsCMPart Part = EnvDTE.vsCMPart.vsCMPartWholeWithAttributes);
[System.Runtime.InteropServices.DispId(15)]
[System.Runtime.InteropServices.TypeLibFunc(1024)]
public EnvDTE.TextPoint GetStartPoint (EnvDTE.vsCMPart Part = EnvDTE.vsCMPart.vsCMPartWholeWithAttributes);
[<System.Runtime.InteropServices.DispId(15)>]
[<System.Runtime.InteropServices.TypeLibFunc(1024)>]
abstract member GetStartPoint : EnvDTE.vsCMPart -> EnvDTE.TextPoint
Public Function GetStartPoint (Optional Part As vsCMPart = EnvDTE.vsCMPart.vsCMPartWholeWithAttributes) As TextPoint

参数

Part
vsCMPart

可选。 一个 vsCMPart 常数,该常数指定要检索的委托的部分。

返回

TextPoint

TextPoint 对象。

实现

属性

示例

在运行此示例之前,请加载一个具有类的项目,并插入以下代码行以及示例代码。 在添加行和示例代码后,单击 Delegate 该行以将插入点放置在该处,然后运行该示例。

Microsoft.visualbasic.dll

Delegate Sub MySubDelegate(ByVal x As Integer)  

[C#]

public delegate void MySubDelegate(int x);  

Microsoft.visualbasic.dll

Public Sub getStartEndPointExample(ByVal dte As DTE2)  
    Try  
        ' Retrieve the CodeClass at the insertion point.  
        Dim sel As TextSelection = _  
          CType(dte.ActiveDocument.Selection, TextSelection)  
        Dim del As CodeDelegate2 = _  
          CType(sel.ActivePoint.CodeElement( _  
          vsCMElement.vsCMElementDelegate), CodeDelegate2)  
        Dim sb As New System.Text.StringBuilder  

        ' Get the start and endpoint offsest for the delegate.  
        sb.AppendLine("Startpoint: " & _  
          del.GetStartPoint(vsCMPart.vsCMPartBody) _  
          .LineCharOffset.ToString)  
        sb.AppendLine("Endpoint: " & _  
          del.GetEndPoint(vsCMPart.vsCMPartBody) _  
          .LineCharOffset.ToString)  
        MessageBox.Show(sb.ToString)  
    Catch ex As System.Exception  
        MsgBox(ex.ToString)  
    End Try  
End Sub  

注解

TextPoint对象表示委托定义的开头。 Part参数定义要返回的委托部分。

备注

在进行了某些类型的编辑之后,代码模型元素(例如类、结构、函数、特性、委托等)的值可能变为非确定性的,这意味着不能确定它们的值始终保持不变。 有关详细信息,请参阅 "代码模型元素值在 使用代码模型查找代码时 可能发生变化" (Visual Basic) "。

适用于