Appearance of Header and also even and odd rows.

Namespace: Dapfor.Net.Ui
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: 2.10.3.24917 (2.10.3.24917)

Syntax

C#
[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
public sealed class HeaderAppearance
Visual Basic
<TypeConverterAttribute(GetType(ExpandableObjectConverter))>
Public NotInheritable Class HeaderAppearance
Visual C++
[TypeConverterAttribute(typeof(ExpandableObjectConverter))]
public ref class HeaderAppearance sealed
F#
[<SealedAttribute>]
[<TypeConverterAttribute(typeof(ExpandableObjectConverter))>]
type HeaderAppearance =  class end

Remarks

.Net Grid applies different styles for even and odd rows, enabling the programmer to his own color styles and even gradient colors via via Grid.Appearance, via Header.Appearance and Column.Appearance property.

.Net Grid uses appearance inheritance. By default, colors and styles for all grids are taken from Dapfor.Net.Ui.Preferences class. However, these preferences can be overridden for every grid separately via Grid.Appearance property. Then, every Header and Column can override previously set appearance for every hierarchical level individually. And finally, you can also use Row.Appearance and Cell.Appearance properties to change individual appearance of rows and cells, but using of these properties may require allocation of a significant volume of memory.

 Copy imageCopy
public void ColumnPanelAppearance(Grid grid)
{
    //Initialize header and columns
    Header header = new Header();
    header.Add(new Column("Name"));
    header.Add(new Column("Price"));
    header.Add(new Column("Quantity"));
    grid.Headers.Add(header);

    //Set appearance for even and odd rows on all hierarchical levels
    grid.Appearance.EvenRows.BackColor = Color.Gray;
    grid.Appearance.OddRows.BackColor = Color.Black;

    //Set appearance for even and odd rows on the top hierarchical level
    header.Appearance.EvenRows.BackColor = Color.Gray;
    header.Appearance.OddRows.BackColor = Color.Black;

    //Default appearance for all columns 
    header.Appearance.ColumnPanel.ForeColor = Color.Red;
    header.Appearance.ColumnPanel.BackColor = Color.LightSteelBlue;
    header.Appearance.ColumnPanel.GradientEnabled = true;
    header.Appearance.ColumnPanel.GradientDirection = GradientDirection.Vertical;
    header.Appearance.ColumnPanel.GradientEndBackColor = Color.LightGray;

    //Appearance of the column 'Price'
    header["Price"].Appearance.CaptionColor.ForeColor = Color.Yellow;
    header["Price"].Appearance.CaptionColor.BackColor = Color.SteelBlue;
    header["Price"].Appearance.CaptionColor.GradientEnabled = true;
    header["Price"].Appearance.CaptionColor.GradientDirection = GradientDirection.Vertical;
    header["Price"].Appearance.CaptionColor.GradientEndBackColor = Color.Gray;


    //Populate the grid with rows
    grid.Rows.Add(new Product());
    Row row = grid.Rows[0];

    //Set a back color for the cell
    row["Price"].Appearance.BackColor = Color.Green;
}

If you are interested in maximum performance of the grid, you should subscribe for Grid.PaintCell event to change appearance instead of setting Row.Appearance and Cell.Appearance properties:

 Copy imageCopy
grid.PaintCell += delegate(object sender, PaintCellEventArgs e)
{
    //custom paint...
    e.Appearance.BackColor = Color.Red;
    e.Font = SystemFonts.MenuFont;
}

Inheritance Hierarchy

System..::..Object
  Dapfor.Net.Ui..::..Header..::..HeaderAppearance

Thread Safety

The class is not thread safe

See Also