Skip to main content

Styles

  • 2 minutes to read

ExpressQuantumGrid is a very powerful and flexible data-aware control. One of the major features contributing to this flexibility is styles. Styles allow you to customize the appearance of grid control elements such as Views, items, bands, and grid levels. Each customizable element has a Styles property, which provides access to its style collection. For instance, a Table View declares properties defining styles for the following items:

  • View background;

  • Cells;

  • Filter box;

  • Footer;

  • Groups;

  • Group summary;

  • Group By box;

  • Column headers;

  • Active selection;

  • Inactive selection;

  • Incremental search selection;

  • Indicator;

  • Row preview;

  • Category row;

  • Filter row;

  • New Item Row;

  • Layer’s separator;

  • Separators of a category, filter and new item rows.

A style consists of the Background color, Text Color and Font attributes. The TcxStyle.Color, TcxStyle.TextColor and TcxStyle.Font properties represent these settings respectively.

For instance, if you assign a style to the View’s Styles.Content property, the font and background of all View columns will be determined by this style. However, you can override the appearance of an individual column by setting its Styles.Content property. The following image shows a grid control with the style redefined for the second column:

At design time, styles are set up via a style repository of class TcxStyleRepository. You can add, edit and delete styles via the style repository editor.

A style repository gives you the ability to arrange styles in a style sheet. A style sheet is an effective way to set up a collection of styles for a grid View. For instance, the TcxGridCardViewStyleSheet provides styles specific to a Card View (TcxGridCardView and TcxGridDBCardView).

To apply a style sheet’s styles to a View, use the Styles.StyleSheet property.

The following image shows the StyleSheet Editor activated via the style repository component dialog.

You should not write event handlers when using styles as this contrasts with the custom draw feature. Styles are easier to use, but they are not as flexible as custom painting. For example, you cannot use gradient fill or bitmap graphics using styles. Custom draw is more complex, but provides you with much greater opportunities for customization of the grid’s display.

See Also