Spread ASP.NET 14
FarPoint.Web.Spread Assembly / FarPoint.Web.Spread.Model Namespace / DefaultSheetStyleModel Class / NamedStyles Property
Example


In This Topic
    NamedStyles Property (DefaultSheetStyleModel)
    In This Topic
    Gets or sets the named styles collection for the model.
    Syntax
    'Declaration
     
    Public Overridable Property NamedStyles As NamedStyleCollection
    'Usage
     
    Dim instance As DefaultSheetStyleModel
    Dim value As NamedStyleCollection
     
    instance.NamedStyles = value
     
    value = instance.NamedStyles
    public virtual NamedStyleCollection NamedStyles {get; set;}

    Property Value

    NamedStyleCollection object containing the collection of named styles
    Remarks

    When the NamedStyleCollection property is set, any named styles referenced in the model are reset to the named style in the new named styles collection with the same name, or reset to null if there is no named style in the new named styles collection with the same name.

    Example
    This example creates two NamedStyle object and adds the NamedStyle objects to the NamedStyleCollection. The number of NamedStyle in the collection is returned to a list box. By default, the NamedStyleCollection is shared among the style models.
    private void Page_Load(object sender,System.EventArgs e)
    {
    if(this.IsPostBack)return;
    
    FarPoint.Web.Spread.Model.DefaultSheetStyleModel model=(FarPoint.Web.Spread.Model.DefaultSheetStyleModel)FpSpread1.Sheets[0].StyleModel;
    FarPoint.Web.Spread.NamedStyle style=new FarPoint.Web.Spread.NamedStyle("Yellow");
    style.BackColor=Color.Yellow;
    FpSpread1.NamedStyles.Add(style);
    
    FarPoint.Web.Spread.NamedStyle style1=new FarPoint.Web.Spread.NamedStyle("Red");
    style1.BackColor=Color.Red;
    FpSpread1.NamedStyles.Add(style1);
    
    model.SetDirectName(0,0,"Yellow");
    model.SetDirectName(0,2,"Red");
    
    ListBox1.Items.Add(model.NamedStyles.Count.ToString());
    }
    Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load
    If(IsPostBack)Then Return
    
    Dim model As FarPoint.Web.Spread.Model.DefaultSheetStyleModel=FpSpread1.Sheets(0).StyleModel
    
    Dim style As New FarPoint.Web.Spread.NamedStyle("Yellow")
    style.BackColor=Color.Yellow
    FpSpread1.NamedStyles.Add(style)
    
    Dim style1 As New FarPoint.Web.Spread.NamedStyle("Red")
    style1.BackColor=Color.Red
    FpSpread1.NamedStyles.Add(style1)
    
    model.SetDirectName(0,0,"Yellow")
    model.SetDirectName(0,2,"Red")
    
    ListBox1.Items.Add(model.NamedStyles.Count.ToString())
    End Sub
    See Also