다음을 통해 공유


Window2.CommandBars Property

Definition

Gets a collection of Microsoft.VisualStudio.CommandBars contained in the current window.

public:
 property System::Object ^ CommandBars { System::Object ^ get(); };
public:
 property Platform::Object ^ CommandBars { Platform::Object ^ get(); };
[System.Runtime.InteropServices.DispId(200)]
public object CommandBars { [System.Runtime.InteropServices.DispId(200)] get; }
[<System.Runtime.InteropServices.DispId(200)>]
[<get: System.Runtime.InteropServices.DispId(200)>]
member this.CommandBars : obj
Public ReadOnly Property CommandBars As Object

Property Value

A Microsoft.VisualStudio.CommandBars collection.

Attributes

Examples

This example iterates through the CommandBars collection for the Object Browser window, and then displays the caption of each command in a message box.

Imports EnvDTE  
Imports EnvDTE80  
Sub GetCommandBars(ByVal dte As DTE2)  
    Dim win As Window2 = _  
 CType(DTE.Windows.Item(Constants.vsWindowKindObjectBrowser), Window2)  
    Dim cmdBars As CommandBars = CType(win.CommandBars, CommandBars)  
    Dim aString As String = "The command bars in " & _  
    win.Caption & " are called:" & vbCr  
    For Each cmdBar As CommandBar In cmdBars  
        aString = aString & (cmdBar.Name & vbCr)  
    Next  
    MsgBox(aString)  
End Sub  
using EnvDTE;  
using EnvDTE80;  
using System.Windows.Forms;  
public void GetCommandBars(DTE2 dte)  
{  
    try  
    {  
        Window2 win =  
 (EnvDTE80.Window2)_applicationObject.Windows.Item  
(Constants.vsWindowKindObjectBrowser);  
        CommandBars cmdBars = (CommandBars)win.CommandBars;  
        String aString = null;  
        aString = ("The command bars in " + win.Caption   
+ " are called:" + "\n");  
        foreach (CommandBar cmdBar in cmdBars)  
        {  
            aString = aString + (cmdBar.Name + "\n");  
        }  
        MessageBox.Show(aString);  
    }  
    catch(Exception ex)  
    {  
        MessageBox.Show(ex.Message);  
    }  
}  

Applies to