共用方式為


IConfigureToolboxItem.ConfigureToolboxItem Method

Called by the toolbox service to configure ToolboxItem objects.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
  Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)
  Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)

Syntax

'宣告
Sub ConfigureToolboxItem ( _
    item As ToolboxItem _
)
'用途
Dim instance As IConfigureToolboxItem
Dim item As ToolboxItem

instance.ConfigureToolboxItem(item)
void ConfigureToolboxItem(
    ToolboxItem item
)
void ConfigureToolboxItem(
    ToolboxItem^ item
)
abstract ConfigureToolboxItem : 
        item:ToolboxItem -> unit 
function ConfigureToolboxItem(
    item : ToolboxItem
)

Parameters

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 [T:System.Windows.Forms.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

IConfigureToolboxItem Members

Microsoft.VisualStudio.Shell Namespace

ProvideToolboxItemConfigurationAttribute

ToolboxItem

ProvideAssemblyFilterAttribute

Other Resources

Toolbox (Visual Studio SDK)