Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Collapse]Printing-Exporting
   [Expand]Product Information
   [Expand]Getting Started
   [Expand]Fundamental Concepts
   [Expand]Concepts
   [Collapse]Examples
    [Expand]Print Preview
    [Collapse]Using Bricks
      How to: Use Bricks of Different Types
      How to: Use Modifiers of BrickGraphics
      How to: Draw a Line Brick
      How to: Modify Brick Appearance using Styles
      How to: Unite Bricks into a Non-Separable Group
      How to: Insert a Page Break between Two Bricks
      How to: Create a Non-Printable Brick
      How to: Create a Custom Brick Inherited from a Standard Brick
      How to: Create a Custom Brick Implementing the IBrick Interface
    [Expand]Using Printing Links
    [Expand]Page Header and Footer
    [Expand]Printing DevExpress Controls
    [Expand]Exporting
    [Expand]Miscellaneous
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Create a Custom Brick Inherited from a Standard Brick

The XtraPrinting Library enables you to create your own custom bricks, and use them in your document. In this topic we introduce one of the approaches to accomplishing this task, which requires deriving a custom brick class from one of the existing brick classes (either the BrickBase class, or its descendants). For information on creating custom bricks by implementing the IBrick interface, refer to the How to: Create a Custom Brick Implementing the IBrick Interface tutorial.

Expanded Inheriting a Custom HyperLinkBrick from the TextBrick

Deriving from an existing brick classes allows you quickly create a custom brick and add extra functionality. This example demonstrates how you can create a custom HyperLinkBrick brick. This brick inherits from the TextBrick class, since a TextBrick provides most of the functionality needed for the new brick type.

The purpose of a new brick is to represent hyperlink addresses in a report. This hyperlink is enabled in the report's preview, and the end-user can click it and open a link in the default browser.

The new brick class implements two constructors, used to initialize a HyperLinkBrick class instance. The first constructor has one parameter specifying the url; in this case the displayed hint contains this link. The second one includes two parameters: the url string and the hint text.

The TextBrickBase.ForeColor and TextBrick.Font properties of the base class are hidden and new methods are implemented instead. By default, the Font property sets the text font to be underlined. The ForeColor property sets the text color to blue.

Expanded Using the HyperLinkBrick

Now you can create and add the HyperLinkBrick to your report as demonstrated below.

Note: you can certainly create this brick using the standard brick type, but the HyperLinkBrick class makes this task easier.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E91.

Expanded See Also

How would you rate this topic?​​​​​​​