ComponentOne True DBGrid for WinForms
Customizing the Grid's Appearance / Three-Dimensional vs. Flat Display
In This Topic
    Three-Dimensional vs. Flat Display
    In This Topic

    True DBGrid for WinForms supports a standard, "flat" control appearance, the more attractive three-dimensional appearance used by many controls, and a third that combines the flat appearance with the 3D. By default, the grid's FlatStyle property is set to FlatModeEnum.Standard so that the 3-D look is used. However, this property only controls whether 3D effects are used to draw the grid's border, caption bars, column headings and footings, and the record selector column. It does not affect the grid's data cells or row and column dividers. The following settings are available:

    To achieve a 3D appearance for the entire grid, including its interior, set the following properties either in the designer or in code:

    1. In the Properties window, set the RowDivider style property to Raised. Or, in code:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Me.C1TrueDBGrid1.RowDivider.Style = C1.Win.C1TrueDBGrid.LineStyleEnum.Raised
      

      To write code in C#

      C#
      Copy Code
      this.c1TrueDBGrid1.RowDivider.Style = C1.Win.C1TrueDBGrid.LineStyleEnum.Raised;
      
    2. In the Splits Collection editor, set the Style property toLineStyleEnum.Raised for all ColumnDivider style objects for each split. Or, in code:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Dim C As C1.Win.C1TrueDBGrid.C1DisplayColumn
      For Each C In Me.C1TrueDBGrid1.Splits(0).DisplayColumns
          C.ColumnDivider.Style = C1.Win.C1TrueDBGrid.LineStyleEnum.Inset
      Next
      

      To write code in C#

      C#
      Copy Code
      C1.Win.C1trueDBGrid.C1DisplayColumn C ;
      for each(C in this.C1trueDBGrid1.Splits[0].DisplayColumns)
      {
          C.ColumnDivider.Style = C1.Win.C1TrueDBGrid.LineStyleEnum.Raised;
      }
      
    3. In the Properties window, set the BackColor property of the Normal style to Lavender. Or, in code:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Me.C1TrueDBGrid1.Styles("Normal").BackColor = System.Drawing.Color.Lavender
      

      To write code in C#

      C#
      Copy Code
      this.c1TrueDBGrid1.Styles["Normal"].BackColor = System.Drawing.Color.Lavender;
      

    The resulting grid will look something like this:


    Note that changing the Style property of the RowDivider object to Raised consumes an extra vertical pixel in each data row, resulting in fewer visible rows.

    Try experimenting with other color combinations and divider styles to achieve different 3D effects, as explained in the Borders and Dividing Lines section.

    See Also