GrapeCity MultiRow Windows Forms Documentation
CellStyleName Property
Example 


Gets or sets the name of the NamedCellStyle.
Syntax
<SRDescriptionAttribute("Indicates the name of the NamedCellStyle.")>
<TypeConverterAttribute("GrapeCity.Win.MultiRow.NamedCellStyleNamePropertyConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")>
<RefreshPropertiesAttribute(RefreshProperties.All)>
Public Property CellStyleName As String
Dim instance As NamedCellStyle
Dim value As String
 
instance.CellStyleName = value
 
value = instance.CellStyleName
[SRDescription("Indicates the name of the NamedCellStyle.")]
[TypeConverter("GrapeCity.Win.MultiRow.NamedCellStyleNamePropertyConverter, GrapeCity.Win.MultiRow, Version=7.20.20141.0, Culture=neutral, PublicKeyToken=0f7a722ee3c2bdd9")]
[RefreshProperties(RefreshProperties.All)]
public string CellStyleName {get; set;}

Property Value

A System.String value that represents the name of the NamedCellStyle.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionThe assigned value is a null reference (Nothing in Visual Basic).
System.ArgumentException The assigned value is not a valid name.
Remarks
The CellStyleName property value refers to the owner Template's Template.NamedCellStyles property or the owner GcMultiRow's GcMultiRow.NamedCellStyles property. If the specific name does not exist, the style is used as CellStyle.Empty.
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. This code example is part of a larger example provided for the NamedCellStyle class.
private void Form1_Load(object sender, EventArgs e)
        {
            Template template1 = Template.CreateGridTemplate(20, 50, 21);

            for (int i = 0; i < template1.Row.Cells.Count - 1; i++)
            {
                if (i % 2 == 0)
                {
                    //The even columns use the "AlternatingColumnsDefaultCellStyle"
                    template1.Row.Cells[i].Style = new NamedCellStyle("AlternatingColumnsDefaultCellStyle");
                }
                else
                {
                    //The odd columns use the "ColumnsDefaultCellStyle"
                    template1.Row.Cells[i].Style = new NamedCellStyle("ColumnsDefaultCellStyle");
                }
            }
            gcMultiRow1.Template = template1;
            gcMultiRow1.RowCount = 20;
        }
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Dim template1 As Template = Template.CreateGridTemplate(20, 50, 21)

        For i As Integer = 0 To template1.Row.Cells.Count - 2
            If i Mod 2 = 0 Then
                'The even columns use the "AlternatingColumnsDefaultCellStyle"
                template1.Row.Cells(i).Style = New NamedCellStyle("AlternatingColumnsDefaultCellStyle")
            Else
                'The odd columns use the "ColumnsDefaultCellStyle"
                template1.Row.Cells(i).Style = New NamedCellStyle("ColumnsDefaultCellStyle")
            End If
        Next

        gcMultiRow1.Template = template1
        gcMultiRow1.RowCount = 20
    End Sub
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 Class
NamedCellStyle Members

 

 


Copyright © GrapeCity, inc. All rights reserved.