Compartir a través de


IConfigureToolboxItem.ConfigureToolboxItem Method

Called by the toolbox service to configure ToolboxItem objects.

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.12.0 (in Microsoft.VisualStudio.Shell.12.0.dll)

Syntax

'Declaration
Sub ConfigureToolboxItem ( _
    item As ToolboxItem _
)
void ConfigureToolboxItem(
    ToolboxItem item
)
void ConfigureToolboxItem(
    ToolboxItem^ item
)
abstract ConfigureToolboxItem : 
        item:ToolboxItem -> unit
function ConfigureToolboxItem(
    item : ToolboxItem
)

Parameters

  • item
    Type: ToolboxItem

    [in] The ToolboxItem object whose configuration is to be modified.

Remarks

The toolbox service calls this method when ToolboxItem objects are first added to the Toolbox, or when the Toolbox is reset. This method modifies data in its properties dictionary of the specified ToolboxItem and. These modifications are serialized and stored as Visual Studio IDE user settings.

Examples

In the example below, the class ToolboxItemConfig implements the IConfigureToolboxItem interface for all libraries in the Vsip namespace. This implementation sets the ToolboxItemFilterAttribute for the toolbox item ToolboxControl1 so that it is available in the Toolbox only when editing a UserControl, and for the toolbox item ToolboxControl2 so that it is not available in the Toolbox when editing a UserControl.

namespace Vsip.ItemConfiguration {
    [ProvideAssemblyFilterAttribute("Vsip.*, Version=*, Culture=*, PublicKeyToken=*")]
    [Guid("11BA3E17-12F1-4e48-9E34-AC68335CD9EE")]
    public sealed class ToolboxConfig : IConfigureToolboxItem {
        ...
        public void ConfigureToolboxItem(ToolboxItem item) {
            if (item == null)
                return;
            ToolboxItemFilterAttribute newFilter = null;
            if (item.TypeName == typeof(ToolboxControl1).ToString()) {
                newFilter = new ToolboxItemFilterAttribute("System.Windows.Forms.UserControl",
                                                   ToolboxItemFilterType.Require);
            } 
            else if (item.TypeName == typeof(ToolboxControl2).ToString()) {
                newFilter = new ToolboxItemFilterAttribute("System.Windows.Forms.UserControl",
                                                      ToolboxItemFilterType.Prevent);
            }
            if (newFilter != null) {
                ArrayList array = new ArrayList();
                array.Add(newFilter);
                item.Filter = (ToolboxItemFilterAttribute[])
                        array.ToArray(typeof(ToolboxItemFilterAttribute));
            }
        }
    }
}

.NET Framework Security

See Also

Reference

IConfigureToolboxItem Interface

Microsoft.VisualStudio.Shell Namespace

ProvideToolboxItemConfigurationAttribute

ToolboxItem

ProvideAssemblyFilterAttribute

Other Resources

Toolbox (Visual Studio SDK)