Spread Silverlight Documentation
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 System.Integer
'Usage
 
Dim instance As StyleInfoCollection
Dim style As StyleInfo
Dim value As System.Integer
 
value = instance.Add(style)
public virtual System.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 creates a named style and adds it to the collection.
gcSpreadSheet1.Sheets[0].NamedStyles.Add(new GrapeCity.Windows.SpreadSheet.Data.StyleInfo() { Background = new SolidColorBrush(Colors.Red), Name = "aaa", VerticalAlignment = GrapeCity.Windows.SpreadSheet.Data.CellVerticalAlignment.Center } );
var style = new GrapeCity.Windows.SpreadSheet.Data.StyleInfo();
gcSpreadSheet1.Sheets[0].Cells[0, 0].StyleName = "aaa";
gcSpreadSheet1.Sheets[0].Rows[7].StyleName = "aaa";
style.Background = new SolidColorBrush(Colors.Blue);
style.BorderLeft = new GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red);
style.BorderTop = new GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red);
style.BorderRight = new GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red);
style.BorderBottom = new GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red);    
//Style applied to a rule
var rule = GrapeCity.Windows.SpreadSheet.Data.AverageRule.Create(GrapeCity.Windows.SpreadSheet.Data.AverageConditionType.Above, style);
rule.Ranges = new GrapeCity.Windows.SpreadSheet.Data.CellRange[] { new GrapeCity.Windows.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;
gcSpreadSheet1.Invalidate(); 

private void button1_Click(object sender, RoutedEventArgs e)
        {
            gcSpreadSheet1.Sheets[0].Cells[0, 0].ResetStyleName();
            gcSpreadSheet1.Invalidate();
        }
GcSpreadSheet1.Sheets(0).NamedStyles.Add(New GrapeCity.Windows.SpreadSheet.Data.StyleInfo() With {.Background = New SolidColorBrush(Colors.Red), .Name = "aaa", .VerticalAlignment = GrapeCity.Windows.SpreadSheet.Data.CellVerticalAlignment.Center})
GcSpreadSheet1.Sheets(0).Cells(0, 0).StyleName = "aaa"
GcSpreadSheet1.Sheets(0).Rows(7).StyleName = "aaa"
Dim style As New GrapeCity.Windows.SpreadSheet.Data.StyleInfo()
style.Background = New SolidColorBrush(Colors.Blue)
style.BorderLeft = New GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red)
style.BorderTop = New GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red)
style.BorderRight = New GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red)
style.BorderBottom = New GrapeCity.Windows.SpreadSheet.Data.BorderLine(Colors.Red)
'Style applied to a rule
Dim rule = GrapeCity.Windows.SpreadSheet.Data.AverageRule.Create(GrapeCity.Windows.SpreadSheet.Data.AverageConditionType.Above, Style)
rule.Ranges = New GrapeCity.Windows.SpreadSheet.Data.CellRange() {New GrapeCity.Windows.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
GcSpreadSheet1.Invalidate()

Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
GcSpreadSheet1.Sheets(0).Cells(0, 0).ResetStyleName()
GcSpreadSheet1.Invalidate()
End Sub
Requirements

Target Platforms: Windows 7, Windows 8 Desktop, Windows Vista SP1 or later, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6

See Also

Reference

StyleInfoCollection Class
StyleInfoCollection Members
Overload List

 

 


Copyright © GrapeCity, inc. All rights reserved.