Udostępnij za pośrednictwem


IConfigureToolboxItem.ConfigureToolboxItem(ToolboxItem) Method

Definition

Called by the toolbox service to configure ToolboxItem objects.

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)

Parameters

item
ToolboxItem

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

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));  
            }  
        }  
    }  
}  

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.

Applies to