Quantcast
Viewing all articles
Browse latest Browse all 7205

How to implement a Control Template Gallery in the End-User Designer to provide the capability to create reusable control sets

This example demonstrates how to add the capability to save selected controls and reuse them in this or other reports like UserControls in standard Windows Forms application.

Implementation Details:
In the scope of this example, we add a custom End-User Designer DockPanel and fill it from the predefined storage (if this storage is not empty), which can be passed to the constructor or Storage property of a custom ReportDesignTool descendant. The storage should implement the IControlTemplateStorage interface, which declares the following members:

- GetCategoryNames. This method should return string representations of all template categories in your storage.
- GetTemplateNamesForCategory. This method returns template names for the specified category.
- GetData. This method returns a byte array containing stored controls.
- SetData. This method allows you to save a byte array representing saved controls.
- DeleteTemplate. Use this method to delete the specified template from your storage.
- DeleteCategory. Use this method to delete the specified category and inner templates.

In this Code example, you can find two sample implementations of this interface. The first one (ControlTemplateStorage) demonstrates how to create an in-memory storage, and the second one uses a DataSet instance for storing templates.

UI for Template Gallery:
As stated above, we added a custom Dock Panel that has two buttons (Add and Delete) for operating with templates and a TreeList instance that displays existing categories and templates. To create a new template, select the required controls in your report and click the Add button. You will see a new dialog requesting the Category and Template name.

To create controls from a template, select the required template in the TreeList and drag-and-drop it to a report design surface at the required location.

To delete a template or category, select it in the TreeList and click the Delete button.

Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>