مشاركة عبر


كيفية القيام بما يلي: عنصر تحكم مربع أدوات التحكم

The ToolBox كائن هو represented في the Visual Studio automation model بواسطة the following الكائنات و collections:

اسم الكائن

الوصف

ToolBoxكائن

Represents the مربع الأدوات.

ToolBoxTabsمجموعة

Represents الجميع علامات التبويب في the مربع الأدوات.

ToolBoxTab2كائن

تمثل علامة تبويب في من مربع الأدوات.

ToolBoxItem2مجموعة

مجموعة تحتوي على كل العناصر الموجودة في علامة تبويب من من مربع الأدوات.

ToolBoxItemكائن

يمثل واحدة العنصر في علامة تبويب من من مربع الأدوات.

بواسطة using these الكائنات و collections, you can:

  • إضافة علامة تبويب إلى مربع الأدوات (Addأسلوب).

  • قم بتنشيط ضمن مربع الأدوات (Activateأسلوب).

  • يحذف علامة تبويب من مربع الأدوات (Deleteأسلوب).

  • إضافة عنصر إلى مربع الأدوات (Addأسلوب).

  • تحديد عنصرا في مربع الأدوات (Selectأسلوب).

  • حذف عنصر من ضمن مربع الأدوات (Deleteأسلوب).

  • تغيير عرض رمز إلى للعرض التقديمي قائمة المهام أو القائمة طريقة العرض ( ListViewخاصية).

بالإضافة إلى التحكم في المحتويات من مربع الأدوات، يمكنك أيضا التحكم بالصفات المميزة لها، مثل كـ العرض والارتفاع. لمزيد من المعلومات، راجع كيفية القيام بما يلي: الصفات المميزة لإطار تغيير.

ملاحظة

مربعات حوار و commوs القائمة التي تظهر التي قد تختلف عن تلك الموضحة في التعليمات استناداً إلى إعدادات النشطة أو نسخة الخاص بك. تم تطوير هذه الإجراءات باستخدام "إعدادات تطوير عامة" نشطة. To change your settings, choose Import and Export Settings on the Tools menu. لمزيد من المعلومات، راجع العمل مع إعدادات.

مثال

يوضح هذا المثال كيفية مرجع واستخدام الأعضاء طراز التنفيذ التلقائي مربع أدوات التحكم المختلفة. هذا المثال ينشئ تبويب "مربع أدوات التحكم ، قم بإضافة عناصر قليلة لها (بما في ذلك.NET مكوّن)، ثم يقوم بحذف أي منها. بشكل اختياري، يمكنك يحذف علامة تبويب جديدة كـ أيضا. For المزيد معلومات حول how إلى تشغيل the مثال, see كيفية القيام بما يلي: ترجمة و تشغيل أمثلة تعليمات برمجية طراز كائن للتنفيذ التلقائي.

' VSMacro
Sub ToolboxExample()
    Dim tlBox As ToolBox
    Dim tbxTabs As ToolBoxTabs
    Dim tbxTab As ToolBoxTab
    Dim tbxItems As ToolBoxItems
    Dim tbxItem As ToolBoxItem

    Try
        ' Create an object reference to the IDE's ToolBox object and
        ' its tabs.
        tlBox = DTE.Windows.Item(Constants.vsWindowKindToolbox).Object
        tbxTabs = tlBox.ToolBoxTabs

        ' Add a new tab to the Toolbox and select it.
        tbxTab = tbxTabs.Add("New ToolBox Tab")
        tbxTab.Activate()

        ' Add new items to the new Toolbox tab. This shows two
        ' different ways to index the Toolbox tabs. The third item
        ' added is a .NET component that contains a number of 
        ' Web-related controls.
        tbxTab.ToolBoxItems.Add("Text Item", "Hello world")
        tbxTab.ToolBoxItems.Add("HTML Item", "Hello world", _
        vsToolBoxItemFormat.vsToolBoxItemFormatHTML)
        ' Replace the <Path and name of a .NET dll>
        ' with a path to a .NET dll file.
        tbxTabs.Item("New Toolbox Tab").ToolBoxItems.Add _
        ("DotNET Component", "< Path and name of a .NET dll >", _
 vsToolBoxItemFormat. _
        vsToolBoxItemFormatDotNETComponent)
        
        ' Use the ToolboxItems collection to access all the items under 
        ' a ToolBox tab.
        tbxItems = tbxTab.ToolBoxItems

        ' List the number of ToolboxItems in a ToolBoxTab.
        MsgBox _
("Number of items in " & tbxTabs.Item(1).Name & " tab: "  _
& tbxItems.Count)

        ' Select the second item in the ToolboxItems collection and 
        ' delete it.
        tbxItems.Item(2).Select()
        If (MsgBox("Delete the second ToolBox item?", vbYesNo) = vbYes) _
        Then
            tbxItems.SelectedItem.Delete()
            MsgBox("Number of items in " & tbxTabs.Item(1).Name & " _
            tab: " & tbxItems.Count)
        End If
        If (MsgBox("Delete the new tab?", vbYesNo) = vbYes) Then
            tbxTabs.Item("New ToolBox Tab").Delete()
            MsgBox("Tab deleted.")
        End If
    Catch ex As System.Exception
        MsgBox("ERROR: " & ex.Message)
    End Try
End Sub
Using System.Windows.Forms;
public void OnConnection(object application,
 Extensibility.ext_ConnectMode connectMode, object addInInst, ref
 System.Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    ToolboxExample(_applicationObject); 
}

public void ToolboxExample( DTE2 dte ) 
{ 
    ToolBox tlBox = null; 
    ToolBoxTabs tbxTabs = null; 
    ToolBoxTab2 tbxTab = null; 
    ToolBoxItems tbxItems = null; 
    ToolBoxItem2 tbxItem = null; 

    try 
    { 
        // Create an object reference to the IDE's ToolBox object and
        // its tabs.
        tlBox = (ToolBox )( dte.Windows.Item(
 Constants.vsWindowKindToolbox ).Object ); 
        tbxTabs = tlBox.ToolBoxTabs; 

        // Add a new tab to the Toolbox and select it.
        tbxTab = (ToolBoxTab2)tbxTabs.Add( "New ToolBox Tab" ); 
        tbxTab.Activate(); 

        // Add new items to the new Toolbox tab. This shows two
        // different ways to index the Toolbox tabs. The third item
        // added is a .NET component that contains a number of 
        // Web-related controls.
        tbxTab.ToolBoxItems.Add( "Text Item", "Hello world",
 (EnvDTE.vsToolBoxItemFormat.vsToolBoxItemFormatText)); 
        tbxTab.ToolBoxItems.Add( "HTML Item", "Hello world"
, vsToolBoxItemFormat.vsToolBoxItemFormatHTML ); 
        // Replace the <Path and name of a .NET dll>
        // with a path to a .NET dll file.
        tbxTabs.Item( "New Toolbox Tab" ).ToolBoxItems.Add
( "DotNET Component",
 "<Path and name of a .NET dll>",
 vsToolBoxItemFormat.vsToolBoxItemFormatDotNETComponent ); 

        // Use the ToolboxItems collection to access all the 
        // items under a ToolBox tab.
        tbxItems = tbxTab.ToolBoxItems; 

        // List the number of ToolboxItems in a ToolBoxTab.
        MessageBox.Show( "Number of items in " +
 tbxTabs.Item( 1 ).Name + " tab: " + tbxItems.Count); 
          
        // Select the second item in the ToolboxItems collection and 
        // delete it.
        // Comment the following lines out, if you do not want to
        // delete the controls.
        tbxItems.Item( 2 ).Select(); 
        
        tbxItems.SelectedItem.Delete(); 
        MessageBox.Show( "Number of items in " 
+ tbxTabs.Item( 1 ).Name + " tab: " + tbxItems.Count); 
        tbxTabs.Item( "New ToolBox Tab" ).Delete(); 
        MessageBox.Show( "Tab deleted."); 
        
    } 
    catch ( System.Exception ex ) 
    { 
        MessageBox.Show( "ERROR: " + ex.Message); 
    } 
}

أمان

إضافة كائن COM التي يجب مسجَّل إلى مربع الأدوات يحاول مسجَّل مكون COM. فشل التسجيل في حالة عدم تسجيل الدخول كمسؤول (أو كعضو مجموعة Administrators (المسؤولون) (Administrators))، و لا يتم تمت الإضافة الكائن COM إلى من مربع الأدوات.

لا يمكنك استعراض ل و إضافة COM مكونات غير مسجَّل إلى مربع أدوات التحكم بغض النظر عن المستوى الأذونات الخاص بك.

راجع أيضًا:

المهام

كيفية القيام بما يلي: الصفات المميزة لإطار تغيير

كيفية القيام بما يلي: قم بإنشاء إضافة-في

الإرشادات التفصيلية: إنشاء معالج

المبادئ

مخطط نموذج كائن تلقائي

موارد أخرى

إنشاء و التحكم في بيئة Windows

إنشاء إضافة-زر 'Ins' ومعالجات

التنفيذ التلقائي والمرجع الامتداد