EditPoint.TryToShow 方法 (vsPaneShowHow, Object)

尝试显示文本点的位置。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Function TryToShow ( _
    How As vsPaneShowHow, _
    PointOrCount As Object _
) As Boolean
bool TryToShow(
    vsPaneShowHow How,
    Object PointOrCount
)
bool TryToShow(
    [InAttribute] vsPaneShowHow How, 
    [InAttribute] Object^ PointOrCount
)
abstract TryToShow : 
        How:vsPaneShowHow * 
        PointOrCount:Object -> bool 
function TryToShow(
    How : vsPaneShowHow, 
    PointOrCount : Object
) : boolean

参数

  • PointOrCount
    类型:System.Object
    可选。要显示的文本的选定范围的终结点。它可以是一个 TextPoint,也可以是一个整数。

返回值

类型:System.Boolean
如果文本的跨距在当前代码编辑器内,则为 true;否则为 false。

备注

如果可能,TryToShow 调整代码视图中缓冲区的位置,以便在代码编辑器中显示指示的文本范围。 TryToShowTextPane 对象的 Activate 方法相似,不同的是它尝试显示窗口和指定的文本范围。

示例

Sub TryToShowExample(ByVal dte As DTE2)

    ' Before running this example, open a text document.
    Dim win As Window = dte.ActiveWindow
    Dim textWin As TextWindow = CType(win.Object, TextWindow)

    ' Split the text document window.
    Dim cmd As Command = dte.Commands.Item("Window.Split")
    dte.Commands.Raise(cmd.Guid, cmd.ID, Nothing, Nothing)

    ' Display the beginning of the document in the top pane and the 
    ' end of the document in the bottom pane.
    Dim sel As TextSelection = textWin.Panes.Item(2).Selection
    sel.StartOfDocument()
    sel.ActivePoint.TryToShow()
    sel = textWin.Panes.Item(1).Selection
    sel.EndOfDocument()
    sel.ActivePoint.TryToShow()

End Sub
public void TryToShowExample(DTE2 dte)
{
    // Before running this example, open a text document.
    Window win = dte.ActiveWindow;
    TextWindow textWin = (TextWindow)win.Object;

    // Split the text document window.
    Command cmd = dte.Commands.Item("Window.Split", -1);
    object dummy = null;
    dte.Commands.Raise(cmd.Guid, cmd.ID, ref dummy, ref dummy);

    // Display the beginning of the document in the top pane and the 
    // end of the document in the bottom pane.
    TextSelection sel = textWin.Panes.Item(2).Selection;
    sel.StartOfDocument(false);
    sel.ActivePoint.TryToShow(vsPaneShowHow.vsPaneShowCentered, null);
    sel = textWin.Panes.Item(1).Selection;
    sel.EndOfDocument(false);
    sel.ActivePoint.TryToShow(vsPaneShowHow.vsPaneShowCentered, null);
}

.NET Framework 安全性

请参见

参考

EditPoint 接口

TryToShow 重载

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例