FlexPivot for WinForms
CellStyle クラス
メンバ  使用例 

C1.Win.C1FlexGrid.4.5.2 アセンブリ > C1.Win.C1FlexGrid 名前空間 : CellStyle クラス
The CellStyle class encapsulates properties that control the appearance of grid cells. This information includes the background and foreground colors, font, text and image alignment, etc.
オブジェクト モデル
CellStyle クラス
シンタックス
'宣言
 
Public Class CellStyle 
public 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.

使用例
The example below creates three CellStyle objects and assigns them to grid rows, columns, and cell ranges.

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

参照

CellStyle メンバ
C1.Win.C1FlexGrid 名前空間