Package.FindToolWindow Method (Type, Int32, Boolean)
Visual Studio 2015
Gets the tool window corresponding to the specified type and ID.
Assembly: Microsoft.VisualStudio.Shell.14.0 (in Microsoft.VisualStudio.Shell.14.0.dll)
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.ToolWindowPaneAn instance of the requested tool window. If create is false and the tool window does not exist, null is returned.
| Exception | Condition |
|---|---|
| ArgumentNullException | toolWindowType is null. |
| ArgumentException |
|
The FindToolWindow method returns a tool window and creates it if requested.
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();
}
Show: