Spread for ASP.NET 10 Product Documentation
Changed Event (NamedStyleCollection)
Example 


Occurs when a style is added, removed, or changed in the collection.
Syntax
'Declaration
 
Public Event Changed As NamedStyleCollectionEventHandler
'Usage
 
Dim instance As NamedStyleCollection
Dim handler As NamedStyleCollectionEventHandler
 
AddHandler instance.Changed, handler
public event NamedStyleCollectionEventHandler Changed
Event Data

The event handler receives an argument of type NamedStyleCollectionEventArgs containing data related to this event. The following NamedStyleCollectionEventArgs properties provide information specific to this event.

PropertyDescription
NewStyleGets the new style that was added, or null if no style was added.  
OldStyleGets the old style that was removed or changed, or null if no style was removed or changed.  
TypeGets the type of event that occurred.  
Example
This example causes the Changed event to occur for the NamedStyleCollection object.
FarPoint.Web.Spread.NamedStyleCollection nsc;

private void PageLoad(object sender, System.EventArgs e)
{
    this.nsc = new FarPoint.Web.Spread.NamedStyleCollection();
    this.nsc.Changed += new FarPoint.Web.Spread.NamedStyleCollectionEventHandler(this.nscChanged);
    FarPoint.Web.Spread.NamedStyle ns = new FarPoint.Web.Spread.NamedStyle("StyleData", "DataAreaDefault");
    FarPoint.Web.Spread.NamedStyle ns1 = new FarPoint.Web.Spread.NamedStyle("HeaderData", "HeaderDefault");
    ns.BackColor = Color.Yellow;
    ns.Border = new FarPoint.Web.Spread.Border(BorderStyle.Double, Color.Blue);
    ns1.BackColor = Color.Teal;
    ns1.Border = new FarPoint.Web.Spread.Border(BorderStyle.Double, Color.Red);
    nsc.AddRange(new Object[] {ns, ns1});
    FpSpread1.NamedStyles.Add(ns1);
    FpSpread1.ActiveSheetView.ColumnHeader.DefaultStyle = ns1;
    if(IsPostBack)
    {
        nsc.Remove(ns1);
        IEnumerator ie = nsc.GetEnumerator();
        foreach(FarPoint.Web.Spread.NamedStyle n in nsc)
        {
            ie.MoveNext();
            FpSpread1.NamedStyles.Add((FarPoint.Web.Spread.NamedStyle)ie.Current);
            FpSpread1.ActiveSheetView.ColumnHeader.DefaultStyle = (FarPoint.Web.Spread.NamedStyle)ie.Current;
        }
    }
}

private void nscChanged(object sender, FarPoint.Web.Spread.NamedStyleCollectionEventArgs e)
{
    TextBox1.Text = "The collection has changed!!";
}
Friend WithEvents nsc As FarPoint.Web.Spread.NamedStyleCollection

Private Sub PageLoad(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    nsc = New FarPoint.Web.Spread.NamedStyleCollection
    Dim ns As New FarPoint.Web.Spread.NamedStyle("StyleData", "DataAreaDefault")
    Dim ns1 As New FarPoint.Web.Spread.NamedStyle("HeaderData", "HeaderDefault")
    Dim n As FarPoint.Web.Spread.NamedStyle
    ns.BackColor = Color.Yellow
    ns.Border = New FarPoint.Web.Spread.Border(BorderStyle.Double, Color.Blue)
    ns1.BackColor = Color.Teal
    ns1.Border = New FarPoint.Web.Spread.Border(BorderStyle.Double, Color.Red)
    nsc.AddRange(New Object() {ns, ns1})
    FpSpread1.NamedStyles.Add(ns1)
    FpSpread1.ActiveSheetView.ColumnHeader.DefaultStyle = ns1
    If IsPostBack Then
        nsc.Remove(ns1)
        Dim ie As IEnumerator = nsc.GetEnumerator
        For Each n In nsc
            ie.MoveNext()
            FpSpread1.NamedStyles.Add(ie.Current)
           FpSpread1.ActiveSheetView.ColumnHeader.DefaultStyle = ie.Current
        Next
    End If
End Sub

Private Sub nscChanged(ByVal sender As Object, ByVal e As FarPoint.Web.Spread.NamedStyleCollectionEventArgs) Handles nsc.Changed
    TextBox1.Text = "The collection has changed!!"
End Sub
Requirements

Target Platforms: Windows 7, Windows 8, Windows 10, Windows Vista, Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows XP Professional

See Also

Reference

NamedStyleCollection Class
NamedStyleCollection Members

 

 


Copyright © GrapeCity, inc. All rights reserved.