This example demonstrates how to create custom data-aware controls that have a complex structure. The example consists of two projects:
- DevExpress.XtraReports.CustomControls. Contains all classes and methods related to custom controls.
- CustomControlExample. This project is for testing the aforementioned custom controls. This project invokes End-User Report Designers and Print Previews for both controls.
Take special note of the following classes and methods when examining the CustomControls project:
1. XRTreeList and XRGrid. They are XRControl descendants and contain all required properties and methods related to their visual representation.
1.1. The XRControl.CreatePresenter method allows you to create different presenters for visualizing your control at runtime and design time.
1.2. The XRControl.WriteContentTo method generates the visual representation and passes it to the resulting document.
1.3. The XRControl.CollectAssociatedComponents method allows you to link external objects (data source information and other Component properties) to your control.
1.4. The XRControl.CopyDataProperties method is required to inform your control of how to clone data source related properties.
1.5. The XRControl.CreateCollectionItem method defines how to create new collection items in your control.
1.6. The XRControl.CreateStyles method is responsible for creating specific control styles.
1.7. The XRControl.CreateScripts method creates scripts specific for this control.
2. XRTreeListDesigner and XRGridDesigner. These classes describe the design-time behavior of corresponding controls.
2.1. The XRControlDesigner.GetFilteredProperties method determines what properties should be visible in the Property Grid.
2.2. The XRControlDesigner.RegisterActionLists method fills the XRControl smart tag with required actions.
3. XRTreeListRuntimePresenter and XRGridRuntimePresenter. These classes generate visual representation of your controls.
3.1. The XRControlPresenter.CreateBrick method creates a container brick for displaying the control content.
3.2. The XRControlPresenter.PutStateToBrick method generates inner content based on the current control state.
Important note: the VB.NET solution is for VS 2012 or newer, because it uses new operators that do not exist in VS 2010.
See also:
How to: Create a Numeric Label
How to: Create a Progress Bar Control