Spread Windows Forms 6.0 Product Documentation
Insert Method
See Also  Example Support Options
FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > NamedStyleCollection Class : Insert Method


index
Zero-based index at which to insert the named style
style
Style to insert into the collection

Glossary Item Box

Inserts a style into the collection at the specified index.

Syntax

Visual Basic (Declaration) 
Public Overridable Sub Insert( _
   ByVal index As Integer, _
   ByVal style As NamedStyle _
) 
Visual Basic (Usage)Copy Code
Dim instance As NamedStyleCollection
Dim index As Integer
Dim style As NamedStyle
 
instance.Insert(index, style)
C# 
public virtual void Insert( 
   int index,
   NamedStyle style
)

Parameters

index
Zero-based index at which to insert the named style
style
Style to insert into the collection

Exceptions

ExceptionDescription
System.IndexOutOfRangeException Specified index is out of range; must be between 0 and the total number in the collection
System.ArgumentNullException No style specified or specified style is null

Example

This example inserts a named style at the specified index into the collection.
C#Copy Code
FarPoint.Win.Spread.NamedStyleCollection nsc = new FarPoint.Win.Spread.NamedStyleCollection();
FarPoint.Win.Spread.NamedStyle ns1 = new FarPoint.Win.Spread.NamedStyle();
FarPoint.Win.Spread.NamedStyle ns2 = new FarPoint.Win.Spread.NamedStyle();
FarPoint.Win.Spread.NamedStyle ns3 = new FarPoint.Win.Spread.NamedStyle("btncellstyle");
int i;
ns1.BackColor = Color.LightBlue;
ns2.BackColor = Color.Gray;
ns3.CellType = new FarPoint.Win.Spread.CellType.ButtonCellType();
nsc.AddRange(new Object[] {ns1, ns2});
nsc.Insert(1, ns3);
fpSpread1.NamedStyles = nsc;
fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = nsc[0];
fpSpread1.ActiveSheet.DefaultStyle = nsc[2];
fpSpread1.ActiveSheet.Cells[0, 0].StyleName = "btncellstyle";
i = nsc.IndexOf(ns3);
label1.Text = "The index of btncellstyle in the collection is " + i.ToString(); 
Visual BasicCopy Code
Dim nsc As New FarPoint.Win.Spread.NamedStyleCollection()
Dim ns1 As New FarPoint.Win.Spread.NamedStyle("StyleHeaders", "HeaderDefault")
Dim ns2 As New FarPoint.Win.Spread.NamedStyle("StyleData", "DataAreaDefault")
Dim ns3 As New FarPoint.Win.Spread.NamedStyle("btncellstyle")
Dim i As Integer
ns1.BackColor = Color.LightBlue
ns2.BackColor = Color.Gray
ns3.CellType = New FarPoint.Win.Spread.CellType.ButtonCellType()
nsc.AddRange(New Object() {ns1, ns2})
nsc.Insert(1, ns3)
FpSpread1.NamedStyles = nsc
FpSpread1.ActiveSheet.ColumnHeader.DefaultStyle = nsc(0)
FpSpread1.ActiveSheet.DefaultStyle = nsc(2)
FpSpread1.ActiveSheet.Cells(0, 0).StyleName = "btncellstyle"
i = nsc.IndexOf(ns3)
Label1.Text = "The index of btncellstyle in the collection is " & i.ToString()

Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.