GrapeCity MultiRow Windows Forms Documentation
NamedCellStyle Class
Members  Example 


Represents a special CellStyle that can define a cell style with the name. This class cannot be inherited.
Syntax
<GcSerializableTypeDescriptorAttribute("GrapeCity.Win.MultiRow.NameCellStyleSerializableTypeDescriptor, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
<TypeConverterAttribute("GrapeCity.Win.MultiRow.NamedCellStyleConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
Public NotInheritable Class NamedCellStyle 
   Inherits CellStyle
Dim instance As NamedCellStyle
[GcSerializableTypeDescriptor("GrapeCity.Win.MultiRow.NameCellStyleSerializableTypeDescriptor, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
[TypeConverter("GrapeCity.Win.MultiRow.NamedCellStyleConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
public sealed class NamedCellStyle : CellStyle 
Remarks

The CellStyleName property value refers to the owner Template's Template.NamedCellStyles property or owner GcMultiRow's GcMultiRow.NamedCellStyles property.

Use a NamedCellStyle to save memory if the style can be used by many cells. This also allows the cell style to be managed easily.

You can implement skins with a NamedCellStyle by keeping the cell's Cell.Style property unchanged and by changing the MultiRow control or the Template's NamedCellStyles property.

Example
The following code example shows how to implement the "AlternatingColumnsDefaultCellStyle" and "ColumnsDefaultCellStyle". When the form is loaded, add a Template to the GcMultiRow control. This Template sets the odd columns with "ColumnsDefaultCellStyle" and sets the even columns with "AlternatingColumnsDefaultCellStyle". After the application is running, if you want to change the "AlternatingColumnsDefaultCellStyle" or "ColumnsDefaultCellStyle", you need only change the GcMultiRow.NamedCellStyles's corresponding item and the new CellStyle is applied.
void setSecondNamedCellStyle_Click(object sender, EventArgs e)
       {
           CellStyle alternatingColumnsDefaultCellStyle = new CellStyle();
           alternatingColumnsDefaultCellStyle.BackColor = Color.Orange;
           alternatingColumnsDefaultCellStyle.ForeColor = Color.Black;
           alternatingColumnsDefaultCellStyle.NullValue = "Text";
           //Change the "AlternatingColumnsDefaultCellStyle"
           this.gcMultiRow1.NamedCellStyles["AlternatingColumnsDefaultCellStyle"] = alternatingColumnsDefaultCellStyle;

           CellStyle columnsDefaultCellStyle = new CellStyle();
           columnsDefaultCellStyle.GradientColors = new Color[] { Color.Orange, Color.Lime };
           columnsDefaultCellStyle.GradientDirection = GradientDirection.Center;
           columnsDefaultCellStyle.GradientStyle = GradientStyle.Vertical;
           //columnsDefaultCellStyle.BackColor = Color.FromArgb(230, 255, 230);
           //columnsDefaultCellStyle.ForeColor = Color.Red ;
           columnsDefaultCellStyle.NullValue = "Text";
           
           this.gcMultiRow1.NamedCellStyles["ColumnsDefaultCellStyle"] = columnsDefaultCellStyle;

           //You can load one predefined NamedCellStyleDictionary from one file.
           //this.gcMultiRow1.NamedCellStyles.Load(@"C:\temp\NamedCellStyles.xml");
           //You can save the NamedCellStyleDictionary to one file.
           //this.gcMultiRow1.NamedCellStyles.Save(@"C:\temp\NamedCellStyles.xml");
       }
Private Sub setSecondNamedCellStyle_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setSecondStyle.Click
        Dim alternatingColumnsDefaultCellStyle As New CellStyle()
        alternatingColumnsDefaultCellStyle.BackColor = Color.Orange
        alternatingColumnsDefaultCellStyle.ForeColor = Color.Black
        alternatingColumnsDefaultCellStyle.NullValue = "Text"
        'Change the "AlternatingColumnsDefaultCellStyle"
        Me.gcMultiRow1.NamedCellStyles("AlternatingColumnsDefaultCellStyle") = alternatingColumnsDefaultCellStyle

        Dim columnsDefaultCellStyle As New CellStyle()
        columnsDefaultCellStyle.GradientColors = New Color() {Color.Orange, Color.Lime}
        columnsDefaultCellStyle.GradientDirection = GradientDirection.Center
        columnsDefaultCellStyle.GradientStyle = GradientStyle.Vertical
        'columnsDefaultCellStyle.BackColor = Color.FromArgb(230, 255, 230);
        'columnsDefaultCellStyle.ForeColor = Color.Red ;
        columnsDefaultCellStyle.NullValue = "Text"

        Me.gcMultiRow1.NamedCellStyles("ColumnsDefaultCellStyle") = columnsDefaultCellStyle

        'You can load one predefined NamedCellStyleDictionary from one file.
        'this.gcMultiRow1.NamedCellStyles.Load(@"C:\temp\NamedCellStyles.xml");
        'You can save the NamedCellStyleDictionary to one file.
        'this.gcMultiRow1.NamedCellStyles.Save(@"C:\temp\NamedCellStyles.xml");
    End Sub
Inheritance Hierarchy

System.Object
   GrapeCity.Win.MultiRow.CellStyle
      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

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

 

 


Copyright © GrapeCity, inc. All rights reserved.