ActiveReports 19 .NET Edition
MESCIUS.ActiveReports.Design.Win Assembly / GrapeCity.ActiveReports.Design Namespace / Designer Class / Toolbox Property
Example

In This Topic
    Toolbox Property (Designer)
    In This Topic
    Gets or Sets the IToolboxService for the Report Designer.
    Syntax
    'Declaration
     
    Public Property Toolbox As IToolboxService
    public IToolboxService Toolbox {get; set;}

    Property Value

    An instance of System.Drawing.Design.IToolboxService that provides access to the toolbox service used by the report designer.
    Remarks
    The toolbox service is a key component in the report designer that manages the toolbox items, such as controls and components, which can be dragged onto the report design surface. This property allows for the customization or replacement of the toolbox service, enabling advanced scenarios such as dynamically changing the available toolbox items based on certain conditions.

    Note: Setting this property with a custom implementation of System.Drawing.Design.IToolboxService can significantly alter the behavior and capabilities of the report designer's toolbox. It should be done with understanding of the underlying mechanics and implications.

    Example
    This example illustrates how to add a Designer component and a Toolbox to a Windows Forms application, configuring the Toolbox as the Designer's toolbox. Demonstrates how to control the availability of toolbox items in the designer's toolbox. Then, configure the toolbox with the state provider to control the enabled items. This example shows how to remove a specific item from the toolbox. It demonstrates finding the item by its type name and then removing it.
    class MyForm : Form
    {
    	MyForm()
    	{
    		var designer = new Designer() { Dock = DockStyle.Fill };
    		var toolbox = new Toolbox { Dock = DockStyle.Right };
    		designer.Toolbox = toolbox;
    		Controls.Add(designer);
    		Controls.Add(toolbox);
    	}
    }
    // First, define a state provider by implementing the IToolboxUser interface. This example enables only the BandedListDesigner tool.
    class ToolboxStateProvider : IToolboxUser
    {
    	public bool GetToolSupported(ToolboxItem tool)
    	{
    		if (tool.TypeName == "GrapeCity.ActiveReports.Design.DdrDesigner.Designers.BandedList.BandedListDesigner")
    			return true;
    		return false;
    	}
    	public void ToolPicked(ToolboxItem tool) { }
    }
    toolbox.ConfigureToolboxItems(new ToolboxStateProvider());
    private static void RemoveBandedListFromToolBox(Toolbox toolbox)
    {
    	// Find the item to be removed by its type name.
    	var bandedList = toolbox.GetToolboxItems()
    		.OfType<ToolboxItem>()
    		.Single(items => items.TypeName.EndsWith("BandedListDesigner"));
    	// Remove the found banded list item from the toolbox.
    	toolbox.RemoveToolboxItem(items);
    }
    See Also