C1.Win.C1FlexGrid Namespace : CellStyle Class |
'Declaration
<TypeConverterAttribute("System.ComponentModel.ExpandableObjectConverter, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")> <RefreshPropertiesAttribute(RefreshProperties.Repaint)> <EditorAttribute(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="C1.Win.C1FlexGrid.Design.StyleUITypeEditor, C1.Win.C1FlexGrid.4.Design")> Public Class CellStyle
'Usage
Dim instance As CellStyle
[TypeConverter("System.ComponentModel.ExpandableObjectConverter, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] [RefreshProperties(RefreshProperties.Repaint)] [Editor(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="C1.Win.C1FlexGrid.Design.StyleUITypeEditor, C1.Win.C1FlexGrid.4.Design")] public class CellStyle
[TypeConverter("System.ComponentModel.ExpandableObjectConverter, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] [RefreshProperties(RefreshProperties.Repaint)] [Editor(EditorBaseTypeName="System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", EditorTypeName="C1.Win.C1FlexGrid.Design.StyleUITypeEditor, C1.Win.C1FlexGrid.4.Design")] public ref class CellStyle
The C1FlexGridBase.Styles property exposes a collection of grid styles, and has methods for creating and removing styles from the grid.
You can create and define styles at design time, but right-clicking the grid and selecting the "Edit Styles" menu option.
Styles follow a hierarchical model similar to styles in Microsoft Word or in cascading style sheets. Every property in a CellStyle object may be left unassigned, in which case the value is inherited from a parent style. The parent style is usually the built-in CellStyleCollection.Normal style.
To determine which elements are defined in a particular style, use the DefinedElements property.
When you modify the properties of a CellStyle object, all cells that use that style are automatically repainted to reflect the changes.
Styles may be assigned to CellRange, Row, and Column objects, as shown in the example below.
After running this code, the third column of the grid will be painted with a red background. The third row will be painted with a green background. The cell at the intersection will be painted in red, because column styles have priority over row styles. The remaining style elements for these cells (font, alignment, etc) are not defined in the new styles and are automatically inherited from the parent style (CellStyleCollection.Normal).
The cells around the intersection will have a bold font. The style that defines the bold font does not specify a background color, so that element is inherited from the parent style, which may be the "red", "green", or "normal" styles.
// create style with red background CellStyle cs = _flex.Styles.Add("red"); Style.BackColor = Color.Red; // create style with green background cs = _flex.Styles.Add("green"); Style.BackColor = Color.Green; // create style with bold font cs = _flex.Styles.Add("bold"); Style.Font = new Font("Tahoma", 8, FontStyle.Bold); // assign red style to a column _flex.Cols[3].Style = _flex.Styles["red"]; // assign green style to a row _flex.Rows[3].Style = _flex.Styles["green"]; // assign bold style to a cell range CellRange rg = _flex.GetCellRange(2, 2, 4, 4); rg.Style = _flex.Styles["bold"];
System.Object
C1.Win.C1FlexGrid.CellStyle
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