Spread Windows Forms 10.0 Product Documentation
OldStyle Property
Example 


Gets the old style that was removed or changed, or null if no style was removed or changed.
Syntax
'Declaration
 
Public ReadOnly Property OldStyle As NamedStyle
'Usage
 
Dim instance As NamedStyleCollectionEventArgs
Dim value As NamedStyle
 
value = instance.OldStyle
public NamedStyle OldStyle {get;}

Property Value

NamedStyle object containing the old style removed or changed, or null if no style was removed or changed
Example
This example returns the old style of the collection.
FarPoint.Win.Spread.NamedStyleCollection nsc;

FarPoint.Win.Spread.NamedStyle[] ns = {new FarPoint.Win.Spread.NamedStyle("Style1"),
new FarPoint.Win.Spread.NamedStyle("Style2"),
new FarPoint.Win.Spread.NamedStyle("Style3")};

private void Form1Load(object sender, System.EventArgs e)
{
    nsc = new FarPoint.Win.Spread.NamedStyleCollection();

    this.nsc.Changed += new FarPoint.Win.Spread.NamedStyleCollectionEventHandler(this.nscChanged); 

    ns[0].Font = new Font("Comic Sans Serif", 12);
    ns[0].Name = "StyleHeaders";
    ns[0].Parent = "HeaderDefault";

    nsc.AddRange(ns);

    fpSpread1.NamedStyles = nsc;
    fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = ns[0];
}

private void button1Click(object sender, System.EventArgs e)
{
    ns[1].Font = new Font("MS Sans Serif", 12);
    ns[1].Name = "StyleHeaders2";

    nsc.Add(ns[1]);

    fpSpread1.NamedStyles = nsc;
    fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = ns[1];

}

private void nscChanged(object sender, FarPoint.Win.Spread.NamedStyleCollectionEventArgs e) 
{ 
    try
    {
        MessageBox.Show(e.OldStyle.Name);
    }
    catch (Exception ex)
    {
        MessageBox.Show("No Old Style to Report");
    } 
}
Friend WithEvents nsc As FarPoint.Win.Spread.NamedStyleCollection

Dim ns As FarPoint.Win.Spread.NamedStyle() = {New FarPoint.Win.Spread.NamedStyle("Style1"), 
New FarPoint.Win.Spread.NamedStyle("Style2"), 
New FarPoint.Win.Spread.NamedStyle("Style3")}

Private Sub Form1Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    nsc = New FarPoint.Win.Spread.NamedStyleCollection

    Dim eh As FarPoint.Win.Spread.NamedStyleCollectionEventHandler = AddressOf nscChanged
    AddHandler nsc.Changed, eh

    ns(0).Font = New Font("Comic Sans Serif", 12)
    ns(0).Name = "StyleHeaders"
    ns(0).Parent = "HeaderDefault"

    nsc.AddRange(ns)

    FpSpread1.NamedStyles = nsc
    FpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = ns(0)

End Sub

Private Sub nscChanged(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.NamedStyleCollectionEventArgs) Handles nsc.Changed
    Try
        MessageBox.Show(e.OldStyle.Name)
    Catch ex As Exception
        MessageBox.Show("No Old Style to Report")
    End Try
End Sub

Private Sub Button1Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ns(1).Font = New Font("MS Sans Serif", FontStyle.Bold)
    ns(1).Name = "StyleHeaders2"

    nsc.Add(ns(1))

    FpSpread1.NamedStyles = nsc
    FpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = ns(1)

End Sub
Requirements

Target Platforms: Windows 2000 Professional (SP4), Windows 2000 Server, Windows 2003 Server (SP1), Windows Server 2012 R2, Windows 2008, Windows XP (SP2), Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10

See Also

Reference

NamedStyleCollectionEventArgs Class
NamedStyleCollectionEventArgs Members

 

 


Copyright © GrapeCity, inc. All rights reserved.