Cell Formatting in 10Tec WinForms Grid

(iGrid.NET Control Tour, Step 1 of 6)

Every cell of 10Tec WinForms grid control stores a value of the Object data type (the Value property of the iGCell class), and it can be any value you need.

The displayed representation of this value may differ from the value itself. To get the text representation, iGrid.NET invokes the standard ToString() method of the value or applies to the value a format string if specified. The latter option allows you to use any format string supported by the .NET Framework or even specify your own format providers by implementing the IFormatProvider interface.

Due to the fact that iGCell.Value has the Object data type, you can store values of different data types in the same column without any additional work!

In iGrid you can format each cell INDIVIDUALLY (even in the same column!) using one or all of the following options:

  • Set background and foreground colors.
  • Each cell can have its own font.
  • Many cell text formatting options. Cell text can be left- or right-aligned or centered horizontally and vertically; it can appear on a single line or multiple lines; text can appear with a trailing ellipsis (...) if the cell text is bigger than the cell boundaries.
  • Cells can be indented so selection and drawing starts at the specified offset. You can control the left, top, right and bottom indent independently.
  • Cells can be included or excluded from the selection box for a row.
  • The value of a cell can be formatted using the .NET Framework format strings.

The screenshot below illustrates how you can use these formatting options:

cell formatting options (foreground and background color, font, alignment)

Pay attention to the fact that each row in iGrid.NET can have a different height.

One of the main distinctive features of our WinForms grid is the ability to use styles to format its cells. The iGrid.NET cell style object used for this purpose allows you to define the view and behavior of a cell once and then simply and quickly change these parameters for all the cells it is applied to even if you have hundreds of thousands of cells in your grid.

By default, the Style property of each cell is not initialized and iGrid.NET uses another cell style object which is stored in the column the cell belongs to. This column cell style object is created automatically each time when you create a new column, and the properties of this cell style object are used for formatting the cells without their own styles in this column.

This approach allows you to display all the cells inside one column using the same formatting or to modify the view and behavior of individual cells independently when you assign a style object to a cell.

10Tec DataGrid column headers features »