ComponentOne True DBGrid for WinForms
How to Use Styles / Applying Styles to Cells
In This Topic
    Applying Styles to Cells
    In This Topic

    True DBGrid for WinForms provides three ways to control the display characteristics of individual cells:

    Control Description
    By Status Each grid cell has a cell status that identifies its disposition (any combination of current, modified, part of a selected row, or part of a highlighted row). Using the AddCellStyle method, set style attributes that apply to any possible combination of cell status values.
    By Contents Specify a pattern (called a regular expression) that is used to perform pattern matching on cell contents. When the contents match the pattern supplied in the AddRegexCellStyle method, True DBGrid for WinForms will automatically apply pre-selected style attributes to the cell.
    By Custom Criteria Using the FetchCellStyle (or FetchRowStyle) event, make decisions about cell colors and fonts each time a cell (or row) is displayed.

    Use Style objects defined at design time as arguments to the AddCellStyle and AddRegexCellStyle methods. Or, create a temporary style in code and use it to specify one or more attributes.

    The FetchCellStyle and FetchRowStyle events pass a temporary Style object as the final parameter. By setting its properties, control the appearance of the cell specified by the other event parameters.

    In True DBGrid for WinForms, per-cell font and color control can only be achieved by writing code. However, by creating styles at design time, this code is kept to a minimum. To learn how to create named styles at design time, see Using the C1TrueDBGrid Style Editor.

    See Also