GrapeCity.Xaml.SpreadSheet.Data
Add(StyleInfo) Method
Example 


The style to add.
Adds a style (StyleInfo object) to the collection.
Syntax
'Declaration
 
Public Overloads Overridable Function Add( _
   ByVal style As StyleInfo _
) As Integer
'Usage
 
Dim instance As StyleInfoCollection
Dim style As StyleInfo
Dim value As Integer
 
value = instance.Add(style)
public virtual int Add( 
   StyleInfo style
)

Parameters

style
The style to add.

Return Value

The number of styles in this collection.
Exceptions
ExceptionDescription
System.ArgumentNullException No style specified, or the specified style is null.
Example
This example uses the Add method.
gcSpreadSheet1.Sheets[0].NamedStyles.Add(new GrapeCity.Xaml.SpreadSheet.Data.StyleInfo() { Background = new SolidColorBrush(Windows.UI.Colors.Red), Name = "aaa", VerticalAlignment = GrapeCity.Xaml.SpreadSheet.Data.CellVerticalAlignment.Center } );
var style = new GrapeCity.Xaml.SpreadSheet.Data.StyleInfo();
gcSpreadSheet1.Sheets[0].Cells[0, 0].StyleName = "aaa";
gcSpreadSheet1.Sheets[0].Rows[7].StyleName = "aaa";
style.Background = new SolidColorBrush(Windows.UI.Colors.Blue);
style.BorderLeft = new GrapeCity.Xaml.SpreadSheet.Data.BorderLine(Windows.UI.Colors.Red);
style.BorderTop = new GrapeCity.Xaml.SpreadSheet.Data.BorderLine(Windows.UI.Colors.Red);
style.BorderRight = new GrapeCity.Xaml.SpreadSheet.Data.BorderLine(Windows.UI.Colors.Red);
style.BorderBottom = new GrapeCity.Xaml.SpreadSheet.Data.BorderLine(Windows.UI.Colors.Red);    
//Style applied to a rule
var rule = GrapeCity.Xaml.SpreadSheet.Data.AverageRule.Create(GrapeCity.Xaml.SpreadSheet.Data.AverageConditionType.Above, style);
rule.Ranges = new GrapeCity.Xaml.SpreadSheet.Data.CellRange[] { new GrapeCity.Xaml.SpreadSheet.Data.CellRange(1, 0, 5, 1) };
gcSpreadSheet1.Sheets[0].ConditionalFormats.AddRule(rule);
gcSpreadSheet1.Sheets[0].Cells[2, 0].Value = 25;
gcSpreadSheet1.Sheets[0].Cells[1, 0].Value = 2;

private void button1_Click(object sender, RoutedEventArgs e)
        {
            gcSpreadSheet1.Sheets[0].Cells[0, 0].ResetStyleName();            
        }
GcSpreadSheet1.Sheets(0).NamedStyles.Add(New GrapeCity.Xaml.SpreadSheet.Data.StyleInfo() With {.Background = New SolidColorBrush(Windows.UI.Colors.Red), .Name = "aaa", .VerticalAlignment = GrapeCity.Xaml.SpreadSheet.Data.CellVerticalAlignment.Center})
GcSpreadSheet1.Sheets(0).Cells(0, 0).StyleName = "aaa"
GcSpreadSheet1.Sheets(0).Rows(7).StyleName = "aaa"
Dim style As New GrapeCity.Xaml.SpreadSheet.Data.StyleInfo()
style.Background = New SolidColorBrush(Windows.UI.Colors.Blue)
style.BorderLeft = New GrapeCity.Xaml.SpreadSheet.Data.BorderLine(Windows.UI.Colors.Red)
style.BorderTop = New GrapeCity.Xaml.SpreadSheet.Data.BorderLine(Windows.UI.Colors.Red)
style.BorderRight = New GrapeCity.Xaml.SpreadSheet.Data.BorderLine(Windows.UI.Colors.Red)
style.BorderBottom = New GrapeCity.Xaml.SpreadSheet.Data.BorderLine(Windows.UI.Colors.Red)
'Style applied to a rule
Dim rule = GrapeCity.Xaml.SpreadSheet.Data.AverageRule.Create(GrapeCity.Xaml.SpreadSheet.Data.AverageConditionType.Above, Style)
rule.Ranges = New GrapeCity.Xaml.SpreadSheet.Data.CellRange() {New GrapeCity.Xaml.SpreadSheet.Data.CellRange(1, 0, 5, 1)}
GcSpreadSheet1.Sheets(0).ConditionalFormats.AddRule(rule)
GcSpreadSheet1.Sheets(0).Cells(2, 0).Value = 25
GcSpreadSheet1.Sheets(0).Cells(1, 0).Value = 2

Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
GcSpreadSheet1.Sheets(0).Cells(0, 0).ResetStyleName()
End Sub
Requirements

Target Platforms: Windows Server 2012, Windows RT

See Also

Reference

StyleInfoCollection Class
StyleInfoCollection Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options