Aracılığıyla paylaş


Nasıl yapılır: Araç Kutusunu Denetleme

Visual Studio eklentileri, Visual Studio 2013'te kullanım dışıdır.Eklentilerinizi VSPackage uzantılarına yükseltmelisiniz.Yükseltme hakkında daha fazla bilgi için bkz: SSS: Eklentileri VSPackage Uzantılarına Dönüştürme.

ToolBox İçinde nesnenin temsil Visual Studio tarafından aşağıdaki nesnelerin ve koleksiyonların otomasyon modeli:

Nesne Adı

Tanımlama

ToolBox nesnesi

Temsil eden araç.

ToolBoxTabs koleksiyonu

Tüm sekmeleri gösteren araç.

ToolBoxTab2 nesnesi

Bir sekmede temsil araç.

ToolBoxTab3 nesnesi

Bir sekmede temsil araç.

ToolBoxItem2 koleksiyonu

Sekmesinde tüm öğeleri içeren bir koleksiyon araç.

ToolBoxItem nesnesi

Sekmesinde tek bir öğeyi gösteren araç.

Bu nesneleri ve koleksiyonları kullanarak, şunları yapabilirsiniz:

  • Bir sekme eklemek araç (Add yöntemi).

  • Bir sekmeyi etkinleştirmek araç (Activate yöntemi).

  • Bir sekmesinden silmek araç (Delete yöntemi).

  • Öğe ekleme araç (Add yöntemi).

  • Bir öğe seçin araç (Select yöntemi).

  • İçinde sekmesindeki bir öğeyi silmek araç (Delete yöntemi).

  • Değişiklik Görev listesi sunu simge görünümü veya liste görünümü (ListView özelliği).

İçeriğini denetleme yanı sıra araç, karakteristiklerini, genişlik ve yükseklik de denetleyebilirsiniz.Daha fazla bilgi için bkz. Nasıl yapılır: Pencere Özelliklerini Değiştirme.

[!NOT]

Gördüğünüz iletişim kutuları ve menü komutları, etkin ayarlarınıza ve ürün sürümüne bağlı olarak Yardım menüsünde açıklanana göre farklılık gösterebilir.Bu yordamlar, Genel Geliştirme Ayarları etkin şekilde geliştirilmiştir.Ayarlarınızı değiştirmek için Araçlar menüsünden Ayarlarİçeri Aktar ve Dışarı Aktar'ı seçin.Daha fazla bilgi için bkz. Visual Studio'da Geliştirme Ayarlarını özelleştirme.

Örnek

Bu örnek başvurmak ve çeşitli üyelerini kullanın gösterilmiştir araç otomasyon modeli.Bu örnek, yeni bir oluşturur araç sekme, birkaç öğe (bir .NET bileþeni de dahil olmak üzere) ekler, daha sonra bunlardan birini siler.İsteğe bağlı olarak, yeni bir sekme de silebilirsiniz.Örneği çalıştırma hakkında daha fazla bilgi için bkz. Nasıl yapılır: Otomasyon Nesne Modeli Kod Örnekleri Derleme ve Çalıştırma.

' 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; 
    ToolBoxTab3 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 = (ToolBoxTab3)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); 
    } 
}

Güvenlik

İçin kayıtlı olması gereken bir COM nesnesi ekleyerek araç COM bileşenini kaydetmek çalışır.Kayıt, bir yönetici (veya Administrators grubunun bir üyesi) olarak açmadıysanız ve COM nesnesine eklenmez başarısız olur araç.

Göz atmak ve Kayıtsız COM bileşenine eklemek araç izin düzeyiniz ne olursa olsun.

Ayrıca bkz.

Görevler

Nasıl yapılır: Pencere Özelliklerini Değiştirme

Nasıl yapılır: Eklentiler Oluşturma

İzlenecek yol: Sihirbaz Oluşturma

Kavramlar

Otomasyon Nesne Modeli Grafiği

Diğer Kaynaklar

Ortam Pencereleri Oluşturma ve Denetleme

Eklentiler ve Sihirbazlar Oluşturma

Otomasyon ve Genişletilebilirlik Başvurusu