ToolBoxItem.Select 方法

使此项在集成开发环境 (IDE) 中变为活动。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Sub Select
void Select()
void Select()
abstract Select : unit -> unit
function Select()

备注

此方法使此项在**“工具箱”**中被选中。

示例

Sub SelectExample(ByVal dte As DTE2)

    ' Add a new tab to the ToolBox.
    Dim box As ToolBox = dte.ToolWindows.ToolBox
    Dim tab As ToolBoxTab = box.ToolBoxTabs.Add("Sample ToolBoxTab")

    ' Add two ToolBoxItem objects to the new ToolBox tab.
    Dim item As ToolBoxItem = tab.ToolBoxItems.Add("Text Item", _
        "Hello, text item!")
    tab.ToolBoxItems.Add("HTML Item", "Hello, HTML item!", _
        vsToolBoxItemFormat.vsToolBoxItemFormatHTML)

    ' Select the "Text Item" ToolBox item.
    box.Parent.AutoHides = False
    box.Parent.Activate()
    tab.Activate()
    item.Select()

    If MsgBox("Delete the selected ToolBox item?", MsgBoxStyle.YesNo) _
        = MsgBoxResult.Yes Then
        item.Delete()
    End If

End Sub 
public void SelectExample(DTE2 dte)
{
    // Add a new tab to the ToolBox.
    ToolBox box = dte.ToolWindows.ToolBox;
    ToolBoxTab tab = box.ToolBoxTabs.Add("Sample ToolBoxTab");

    // Add two ToolBoxItem objects to the new ToolBox tab.
    ToolBoxItem item = tab.ToolBoxItems.Add("Text Item", 
        "Hello, text item!", 
        vsToolBoxItemFormat.vsToolBoxItemFormatText);
    tab.ToolBoxItems.Add("HTML Item", "Hello, HTML item!", 
        vsToolBoxItemFormat.vsToolBoxItemFormatHTML);

    // Select the "Text Item" ToolBox item.
    box.Parent.AutoHides = false;
    box.Parent.Activate();
    tab.Activate();
    item.Select();

    if (MessageBox.Show("Delete the selected ToolBox item?", "", 
        MessageBoxButtons.YesNo) == DialogResult.Yes)
        item.Delete();
}

.NET Framework 安全性

请参阅

参考

ToolBoxItem 接口

EnvDTE 命名空间

其他资源

如何:编译和运行自动化对象模型代码示例