Appearance of UI elements (Cell, Column, etc.)

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

Syntax

C#
public class Appearance
Visual Basic
Public Class Appearance
Visual C++
public ref class Appearance
F#
type Appearance =  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 HowToCustomizeAppearance(Grid grid)
{
    //Set default background color for even rows in all the grids
    Preferences.Grid.EvenRowsAppearance.BackColor = Color.White;

    //Create headers and columns
    Header header1 = new Header();
    Column column = new Column("SomeId");
    //Show icons in all cells, belong to this column
    column.CaptionImage = Image.FromFile("SomeImage.jpg");
    header1.Add(column);

    //Add headers to the grid
    Header header2 = new Header();
    grid.Headers.Add(header1);
    grid.Headers.Add(header2);

    //Add a new row to the grid
    Row row = grid.Rows.Add(new SomeObject());

    //Change default behavior and set a new text color for the already added row
    row.Appearance.ForeColor = Color.Green;

    //Change the color only for the specified cell
    row["SomeId"].Appearance.BackColor = Color.Red;  
}

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..::..Appearance

Thread Safety

Any instance members are not guaranteed to be thread safe.

See Also