Compartilhar via


Package.FindToolWindow(Type, Int32, Boolean) Method

Definition

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

public:
 Microsoft::VisualStudio::Shell::ToolWindowPane ^ FindToolWindow(Type ^ toolWindowType, int id, bool create);
public Microsoft.VisualStudio.Shell.ToolWindowPane FindToolWindow (Type toolWindowType, int id, bool create);
member this.FindToolWindow : Type * int * bool -> Microsoft.VisualStudio.Shell.ToolWindowPane
Public Function FindToolWindow (toolWindowType As Type, id As Integer, create As Boolean) As ToolWindowPane

Parameters

toolWindowType
Type

Type of the window to be created

id
Int32

Instance ID

create
Boolean

Create if none exist?

Returns

An instance of a class derived from ToolWindowPane or null if the tool window doesn't derive from ToolWindowPane.

Exceptions

toolWindowType is null.

toolWindowType is not derived from ToolWindowPane. toolWindowType does not have a public constructor .

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();  

}  

Remarks

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

Applies to