GrapeCity MultiRow Windows Forms Documentation
CellStyle Class
Members  Example 


Represents the formatting and style information applied to individual cells within a GcMultiRow control.
Object Model
CellStyle ClassGradientEffect StructureBorderBase ClassICustomWordWrapProvider InterfaceGradientEffect StructureGradientEffect StructureGradientEffect StructureITextAdjustmentProvider Interface
Syntax
<FeatureAttribute(Name="CellStyle", Version="v5.0")>
<TypeConverterAttribute("GrapeCity.Win.MultiRow.CellStyleTypeConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
Public Class CellStyle 
Dim instance As CellStyle
[Feature(Name="CellStyle", Version="v5.0")]
[TypeConverter("GrapeCity.Win.MultiRow.CellStyleTypeConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
public class CellStyle 
Remarks

CellStyle has an inherited policy from the GcMultiRow.Template to GcMultiRow to Section to Cell. All properties in the CellStyle have a specific value that represents an inherited value. The inherited value is always the default property value. If the property value is an inherited value, this means the final value of the cell property is retrieved from the cell's parent and parent's parent, until a value is found that is not inherited. This policy allows GcMultiRow's cells to use a uniform style and behavior. Another benefit is that the Cell or Section can keep an empty CellStyle and use the inherited value from GcMultiRow or Template. This saves memory.

CellStyle provides another policy to make it more flexible. You can change the CellStyle's value in the GcMultiRow.CellFormatting event handler. The event is fired every time the cell gets a formatted value (such as painting a cell). You can automatically assign a CellStyle to the cell. From a performance and flexibility point of view, use the GcMultiRow.CellFormatting event instead of changing the Cell's Style property directly to change a cell's CellStyle.

You can use other inherited CellStyles to create skins or customize more flexible styles.

Example
The following code example shows how to use this type to customize the MultiRow control appearance.
void Form1_Load(object sender, EventArgs e)
       {
           // All cell's will use default cell style.
           gcMultiRow1.RowsDefaultCellStyle.BackColor = Color.Black;
           gcMultiRow1.RowsDefaultCellStyle.ForeColor = Color.White;
           gcMultiRow1.RowsDefaultCellStyle.SelectionBackColor = Color.FromArgb(100, SystemColors.Highlight);
           gcMultiRow1.RowsDefaultCellStyle.TextAlign = MultiRowContentAlignment.MiddleRight;

           // The cell's in alternating Rows
           gcMultiRow1.AlternatingRowsDefaultCellStyle.GradientColors = new Color[] { Color.FromArgb(25, 25, 25), Color.FromArgb(75, 75, 75) };
           gcMultiRow1.AlternatingRowsDefaultCellStyle.GradientDirection = GradientDirection.Backward;
           gcMultiRow1.AlternatingRowsDefaultCellStyle.GradientStyle = GradientStyle.Horizontal;

           // Row header cells
           gcMultiRow1.RowsDefaultHeaderCellStyle.BackColor = Color.FromArgb(75, 75, 75);
           gcMultiRow1.RowsDefaultHeaderCellStyle.ForeColor = Color.White;

           // column header cells.
           gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.BackColor = Color.FromArgb(75, 75, 75);
           gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.ForeColor = Color.FromArgb(200, 200, 200);
           gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.TextAlign = MultiRowContentAlignment.MiddleCenter;
           gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.UseCompatibleTextRendering = MultiRowTriState.True;
           gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.TextEffect = TextEffect.SunkenLite;

           // All cells in specific row.
           gcMultiRow1.Rows[0].DefaultCellStyle.PatternColor = Color.Gray;
           gcMultiRow1.Rows[0].DefaultCellStyle.PatternStyle = MultiRowHatchStyle.BackwardDiagonal;
           gcMultiRow1.Rows[0].DefaultCellStyle.Font = new Font(Control.DefaultFont, FontStyle.Underline);

           // Change single cell
           gcMultiRow1[0, 0].Style.UseCompatibleTextRendering = MultiRowTriState.True;
           gcMultiRow1[0, 0].Style.TextAngle = 30;
           gcMultiRow1[0, 0].Style.Format = "#0.00%";
       }
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        ' All cell's will use default cell style.
        gcMultiRow1.RowsDefaultCellStyle.BackColor = Color.Black
        gcMultiRow1.RowsDefaultCellStyle.ForeColor = Color.White
        gcMultiRow1.RowsDefaultCellStyle.SelectionBackColor = Color.FromArgb(100, SystemColors.Highlight)
        gcMultiRow1.RowsDefaultCellStyle.TextAlign = MultiRowContentAlignment.MiddleRight

        ' The cell's in alternating Rows
        gcMultiRow1.AlternatingRowsDefaultCellStyle.GradientColors = New Color() {Color.FromArgb(25, 25, 25), Color.FromArgb(75, 75, 75)}
        gcMultiRow1.AlternatingRowsDefaultCellStyle.GradientDirection = GradientDirection.Backward
        gcMultiRow1.AlternatingRowsDefaultCellStyle.GradientStyle = GradientStyle.Horizontal

        ' Row header cells
        gcMultiRow1.RowsDefaultHeaderCellStyle.BackColor = Color.FromArgb(75, 75, 75)
        gcMultiRow1.RowsDefaultHeaderCellStyle.ForeColor = Color.White

        ' column header cells.
        gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.BackColor = Color.FromArgb(75, 75, 75)
        gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.ForeColor = Color.FromArgb(200, 200, 200)
        gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.TextAlign = MultiRowContentAlignment.MiddleCenter
        gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.UseCompatibleTextRendering = MultiRowTriState.True
        gcMultiRow1.ColumnHeadersDefaultHeaderCellStyle.TextEffect = TextEffect.SunkenLite

        ' All cells in specific row.
        gcMultiRow1.Rows(0).DefaultCellStyle.PatternColor = Color.Gray
        gcMultiRow1.Rows(0).DefaultCellStyle.PatternStyle = MultiRowHatchStyle.BackwardDiagonal
        gcMultiRow1.Rows(0).DefaultCellStyle.Font = New Font(Control.DefaultFont, FontStyle.Underline)

        ' Change single cell
        gcMultiRow1(0, 0).Style.UseCompatibleTextRendering = MultiRowTriState.True
        gcMultiRow1(0, 0).Style.TextAngle = 30
        gcMultiRow1(0, 0).Style.Format = "#0.00%"
    End Sub
Inheritance Hierarchy

System.Object
   GrapeCity.Win.MultiRow.CellStyle
      GrapeCity.Win.MultiRow.CombinedCellStyle
      GrapeCity.Win.MultiRow.ConditionalCellStyle
      GrapeCity.Win.MultiRow.DynamicCellStyle
      GrapeCity.Win.MultiRow.NamedCellStyle

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

CellStyle Members
GrapeCity.Win.MultiRow Namespace
Cell Class
Section Class
Template Class
GcMultiRow Class
NamedCellStyle Class
ConditionalCellStyle Class
CombinedCellStyle Class
DynamicCellStyle Class

 

 


Copyright © GrapeCity, inc. All rights reserved.