Nevron Open Vision Documentation
Grid / Columns / Column Formats
In This Topic
    Column Formats
    In This Topic
     About Column Formats

    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

    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
    Center - boolean
    Right - the default.

    Extended Column Formats

    NProgressBarColumnFormat A column format that displays a progress bar. NProgressBar none Any type that is convertible to double.



    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:

     Horizontal and Vertical Alignment

    As mentioned the column format is responsible for the creation of cell view widgets that represents row values of a certain type. The cell view widgets that the column format generates are assigned to the NDataCell.Content child. As all widgets they can be aligned to the arrange slot assigned to them by the data cell (see Widget Elements for more info).

    The default vertical alignment of all column formats is Center. The default horizontal alignment of the cell views is column format specific and is summarized in the column formats table above. You can use the HorizontalAlignment and VerticalAlignment properties of the NColumnFormat to alter the default alignment of the cell view widgets inside the data cell, like this:

    Change Cell View Widgets Alignment
    Copy Code
    column.Format.HorizontalAlignment = ENDataCellViewHorizontalAlignment.Right;
    column.Format.VerticalAlignment = ENDataCellViewVerticalAlignment.Top;
     Cell View Appearance

    Since cell view widgets are derived from the NWidget base class, it is possible to format all widgets that are created by a column format with an uniform background, font and text fill. The following code example alters the default appearance of all cell view widgets that are created by a certain column format:

    Change Cell View Widgets Appearance
    Copy Code
    column.Format.BackgroundFill = new NColorFill(NColor.LightSeaGreen);
    column.Format.Font = new NFont("Tahoma", 12);
    column.Format.TextFill = new NColorFill(NColor.DarkGoldenrod);


    See Also