共用方式為


WindowConfigurations.Add 方法

根據視窗目前的排列建立新的具名視窗組態、將它加入 WindowConfigurations 集合,並保留以供日後重新叫用。

命名空間:  EnvDTE
組件:  EnvDTE (在 EnvDTE.dll 中)

語法

'宣告
Function Add ( _
    Name As String _
) As WindowConfiguration
WindowConfiguration Add(
    string Name
)
WindowConfiguration^ Add(
    [InAttribute] String^ Name
)
abstract Add : 
        Name:string -> WindowConfiguration 
function Add(
    Name : String
) : WindowConfiguration

參數

  • Name
    型別:System.String
    必要項。代表新視窗組態之名稱的字串。

傳回值

型別:EnvDTE.WindowConfiguration
WindowConfiguration 物件。

備註

您可以將目前 Visual Studio 環境中的視窗配置儲存為具名的視窗組態。Add 方法可讓您儲存此組態,以供日後透過使用 Apply 方法重新叫用。

範例

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

.NET Framework 安全性

請參閱

參考

WindowConfigurations 介面

EnvDTE 命名空間

其他資源

WindowConfiguration 建立範例

WindowConfiguration 選取範例