This documentation is archived and is not being maintained.

StyleCollection Class

Represents a collection of Style objects.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class StyleCollection : StateManagedCollection

Use the StyleCollection class to store and manage Style objects for a control. Control developers can use this class to contain a set of styles that apply to different portions of the control.

The collection dynamically increases in size as objects are added. Indexes in this collection are zero-based. Use the Count property to determine how many objects are in the collection.

Additionally, use the StyleCollection methods and properties to provide the following functionality:

  • The Add method to add a single style to the collection.

  • The Insert method to add a style at a particular index within the collection.

  • The Remove method to remove a style from the collection.

  • The RemoveAt method to remove the style located at a particular index.

  • The Contains method to determine whether a particular style is already in the collection.

  • The IndexOf method to retrieve the index of a style within the collection.

  • The Clear method to remove all the styles from the collection.

System.Object
  System.Web.UI.StateManagedCollection
    System.Web.UI.WebControls.StyleCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: