EditPoint.TryToShow Method
Attempts to display the text point's location.
Namespace: EnvDTE
Assembly: EnvDTE (in EnvDTE.dll)
Syntax
'Declaration
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
Parameters
- How
Type: EnvDTE.vsPaneShowHow
Optional. A vsPaneShowHow constant that determines how the code is displayed.
- PointOrCount
Type: System.Object
Optional. The endpoint of the selected range of text to be displayed. It can be either a TextPoint or an integer.
Return Value
Type: System.Boolean
true if the span of text fits within the current code editor; otherwise, false.
Implements
TextPoint.TryToShow(vsPaneShowHow, Object)
Remarks
TryToShow adjusts the location of the buffer in the code view so that the indicated range of text is displayed in the code editor, if possible. TryToShow is similar to the TextPane object's Activate method except that it attempts to display the window and the specified range of text.
Examples
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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Other Resources
How to: Compile and Run the Automation Object Model Code Examples