Package.FindToolWindow Method

Gets the tool window corresponding to the specified type and ID.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)
  Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)
  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)

Syntax

声明
Public Function FindToolWindow ( _
    toolWindowType As Type, _
    id As Integer, _
    create As Boolean _
) As ToolWindowPane
用法
Dim instance As Package
Dim toolWindowType As Type
Dim id As Integer
Dim create As Boolean
Dim returnValue As ToolWindowPane

returnValue = instance.FindToolWindow(toolWindowType, _
    id, create)
public ToolWindowPane FindToolWindow(
    Type toolWindowType,
    int id,
    bool create
)
public:
ToolWindowPane^ FindToolWindow(
    Type^ toolWindowType, 
    int id, 
    bool create
)
member FindToolWindow : 
        toolWindowType:Type * 
        id:int * 
        create:bool -> ToolWindowPane 
public function FindToolWindow(
    toolWindowType : Type, 
    id : int, 
    create : boolean
) : ToolWindowPane

Parameters

  • toolWindowType
    Type: System.Type
    The type of tool window to create.
  • id
    Type: System.Int32
    The tool window ID. This is 0 for a single-instance tool window.
  • create
    Type: System.Boolean
    If true, the tool window is created if it does not exist.

Return Value

Type: Microsoft.VisualStudio.Shell.ToolWindowPane
An instance of the requested tool window. If create is false and the tool window does not exist, nulla null reference (Nothing in Visual Basic) is returned.

Exceptions

Exception Condition
ArgumentNullException

toolWindowType is nulla null reference (Nothing in Visual Basic).

ArgumentException
  • toolWindowType is not derived from ToolWindowPane.

  • toolWindowType does not have a public constructor .

Remarks

The FindToolWindow method returns a tool window and creates it if requested.

Examples

private void OnMyMenuCommand(object sender, EventArgs e)
{

    // Locates the tool window. This uses IVSUIShell.FindToolWindow
    // to locate an existing tool window. Because true is passed
    // here as the last parameter, the tool window is created
    // if it does not exist in Visual Studio.
    ToolWindowPane w = _package.FindToolWindow(typeof(MyToolWindow), 0, true);

// Shows the tool window. This calls CreateToolWindow
// on IVSUIShell if the tool window does not exist yet.
    w.Show();

}

.NET Framework Security

See Also

Reference

Package Class

Package Members

Microsoft.VisualStudio.Shell Namespace