The column format is represented by a NColumnFormat derived object. When a data cell is realized, it asks the column format to create a cell view widget (see Widget Elements for more info) that displays the current row value. You can think of the column format as the object responsible for the visualization of the data cell value. The format of a column is accessible from the NColumn.Format property.
A column format is automatically assigned to each column whenever the type of row values for that column becomes known. For NDataColumn instances a format is assigned to the column when the column is bound to a data source field. The table below outlines the default row values type and column format associations (for example for a column of string row values, the NStringColumnFormat is used).
The following image illustrates the current column formats hierarchy:
As you can see from the hierarchy there are two base types of column formats:
- NColumnFormat - an element that serves as base class for all column formats. It defines common aspects of all column formats as horizontal and vertical data cell view alignment, background fill, font and conditional formatting. These aspects of NColumnFormat are discussed in details later in this topic.
- NTextValueColumnFormat<TValueFormatter> - this abstract column format aggregates a NValueFormatter object of the TValueFormatter type. This value formatter object is responsible for creating a string representation of the current row value and is accessible from the ValueFormatter property. Serves as base class for NNumericColumnFormat, NVariantColumnFormat and NDateTimeColumnFormat.
The column formats are also logically divided into two categories:
- Default Column Formats - these are the column formats that the grid by default uses, for specific row values types. For example when a NDataColumn is bound to a string data source field, the grid by default associated the NStringColumnFormat with that column.
- Extended Column Formats - these are column formats that the grid does not use by default, but you can manually assign to certain columns, like this:
Assign column format |
Copy Code
|
---|---|
column.Format = new NProgressBarColumnFormat();
|
The following table describes the available column formats in detail:
Format Type | Description | Cell View Type | Associated with types | Can be bound to types | Default Horizontal Alignment |
---|---|---|---|---|---|
Standard Column Formats |
|||||
NBooleanColumnFormat | Column format associated with Boolean columns. | NTextCellView | Boolean | Boolean | Center |
NDateTimeColumnFormat | Column format associated with D columns. Creates a NTextCellView with the string representation of the date time value. The date time value is formatted with a NDateTimeValueFormatter accessible from the ValueFormatter property. | NTextCellView | DateTime | DateTime | Left |
NEnumColumnFormat | Column format associated with Boolean columns. | NTextCellView | Enums | Enums | Right |
NImageColumnFormat | Column format associated with Image columns. | NImageBox | NRaster, NImage, NImageSource | NRaster, NImage, NImageSource, NFile, string, Stream, byte[] | Center |
NNumericColumnFormat | Numeric column format associated with unsigned integers. Creates a NTextCellView that contains a formatted number representation. | NTextCellView |
Byte, UInt16, UInt32, ULong, Int16, Int32, Long, Float, Double, Decimal |
Byte, UInt16, UInt32, ULong, Int16, Int32, Long, Float, Double, Decimal |
Right |
NObjectColumnFormat | Column format associated with objects for which there is no other associated format (i.e. the default column format). Creates a NTextCellView with the ToString() representation of the object value. | NTextCellView | Object | Object | Left |
NStringColumnFormat | Column format associated with String columns. | NTextCellView | String | String | Left |
NVariantColumnFormat | Column format associated with Variant columns. Creates a NTextCellView with the string representation of the variant value, that is formatted by the NVariantValueFormatter accessible from the ValueFormatter property. | NTextCellView | NVariant | NVariant |
Depending on variant type. Left - for string |
Extended Column Formats |
|||||
NProgressBarColumnFormat | A column format that displays a progress bar. | NProgressBar | none | Any type that is convertible to double. |
Fit |
All column formats share the following set of features that are inherited by the base NColumnFormat object:
- Horizontal and Vertical Alignment
- Cell View Appearance
The rest of the topic discusses the common features of all column formats: