次の方法で共有


WindowConfigurations.Add(String) Method

Definition

Creates a new named window configuration based on the current arrangement of windows, adds it to the WindowConfigurations collection, and retains it for future recall.

public:
 EnvDTE::WindowConfiguration ^ Add(System::String ^ Name);
public:
 EnvDTE::WindowConfiguration ^ Add(Platform::String ^ Name);
EnvDTE::WindowConfiguration Add(std::wstring const & Name);
[System.Runtime.InteropServices.DispId(4)]
public EnvDTE.WindowConfiguration Add (string Name);
[<System.Runtime.InteropServices.DispId(4)>]
abstract member Add : string -> EnvDTE.WindowConfiguration
Public Function Add (Name As String) As WindowConfiguration

Parameters

Name
String

Required. A string representing the name of the new window configuration.

Returns

A WindowConfiguration object.

Attributes

Examples

Sub AddExample(ByVal dte As DTE)  
    ' Set references to all necessary objects.  
    Dim colWinConfig As WindowConfigurations  
    Dim objWinConfig As WindowConfiguration  

    colWinConfig = dte.WindowConfigurations  

    MsgBox("Number of configurations: " & colWinConfig.Count)  
    ' List all saved named window configurations.  
    FillMsg(colWinConfig)  
    ' Create a new window configuration.  
    objWinConfig = colWinConfig.Add("NewLayout")  
    FillMsg(colWinConfig)  
    ' Get rid of the new window configuration.  
    objWinConfig.Delete()  
    MsgBox("Number of configurations: " & colWinConfig.Count)  
    FillMsg(colWinConfig)  
End Sub  

Sub FillMsg(ByVal colWinConfig As Object)  
    ' Lists all currently available named window configurations.  
    Dim lCtr As Integer  
    Dim strMsg As String  

    For lCtr = 1 To colWinConfig.Count  
    strMsg = strMsg & "Configuration name " & lCtr & ": " & _  
    colWinConfig.Item(lCtr).Name & vbCr  
    Next lCtr  
    strMsg = "Current Configurations: " & vbCr & strMsg  
    MsgBox(strMsg)  
End Sub  
void AddExample(_DTE dte)  
{  
    // Set references to all necessary objects.  
    WindowConfigurations colWinConfig;   
    WindowConfiguration objWinConfig;  

    colWinConfig = dte.WindowConfigurations;  
    MessageBox.Show("Number of configurations: " + colWinConfig.Count);  
    // List all saved named window configurations.  
    FillMsg(colWinConfig);  
    // reate a new window configuration.  
    objWinConfig = colWinConfig.Add("NewLayout");  
    FillMsg(colWinConfig);  
    // Get rid of the new window configuration.  
    objWinConfig.Delete();  
    MessageBox.Show("Number of configurations: " + colWinConfig.Count);  
    FillMsg(colWinConfig);  
}  

void FillMsg(WindowConfigurations colWinConfig )  
{  
    // Lists all currently available named window configurations.  
    int lCtr;  
    string strMsg = null;  

    for (lCtr = 1; lCtr < colWinConfig.Count + 1; lCtr ++)  
    {  
        strMsg = strMsg + "Configuration name " + lCtr + ": " +   
        colWinConfig.Item(lCtr).Name + "\n";   
    }  
    strMsg = "Current Configurations: \n" + strMsg;  
    MessageBox.Show(strMsg);  
}  

Remarks

You can save your current window layout in the Visual Studio environment as a named window configuration. The Add method allows you to save this configuration for later recall by using the Apply method.

Applies to