IConfigureToolboxItem.ConfigureToolboxItem(ToolboxItem) 方法

定义

由工具箱服务调用,用于配置 ToolboxItem 对象。

public:
 void ConfigureToolboxItem(System::Drawing::Design::ToolboxItem ^ item);
public void ConfigureToolboxItem (System.Drawing.Design.ToolboxItem item);
abstract member ConfigureToolboxItem : System.Drawing.Design.ToolboxItem -> unit
Public Sub ConfigureToolboxItem (item As ToolboxItem)

参数

item
ToolboxItem

ToolboxItem 要修改其配置的对象。

示例

在下面的示例中,类 ToolboxItemConfig 实现 IConfigureToolboxItem 命名空间中所有库的接口 Vsip 。 此实现设置 " ToolboxItemFilterAttribute 工具箱" 项的 ToolboxControl1 ,以便它仅在编辑时在 "工具箱" 中提供 UserControl ,而对于工具箱项, ToolboxControl2 使其在编辑时 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));  
            }  
        }  
    }  
}  

注解

ToolboxItem 对象首次添加到 " 工具箱" 时,或者在重置 工具箱 时,工具箱服务将调用此方法。 此方法修改指定和的属性字典中的数据 ToolboxItem 。 这些修改将作为 IDE 用户设置进行序列化和存储 Visual Studio 。

适用于