将行设置为标题行

要将行设置为标题行,请为每一行设置CaptionDataType 属性。

1.      将下面的代码添加到Form_Load 事件中来设置将会出现在表格中的行数和列数。

    Visual Basic

Me.C1FlexGrid1.Cols.Count = 5

Me.C1FlexGrid1.Rows.Count = 7

 

    C#

this.c1FlexGrid1.Cols.Count = 5;

this.c1FlexGrid1.Rows.Count = 7;

2.      RowCollection中添加行:

Dim row As C1.Win.C1FlexGrid.RowCollection = Me.C1FlexGrid1.Rows

 

    Visual Basic

 

    C#

C1.Win.C1FlexGrid.RowCollection row = this.c1FlexGrid1.Rows;

 

 

3.      为每一行设置CaptionDataType属性。

    Visual Basic

row(1).Caption = "Date"

row(1).DataType = GetType(DateTime)

row(2).Caption = "Contact"

row(2).DataType = GetType(String)

row(3).Caption = "Phone"

row(3).DataType = GetType(String)

row(3).EditMask = "(999)   999-9999;*"

row(4).Caption = "Platform"

row(4).DataType = GetType(String)

row(4).ComboList = "|Windows XP|Windows 2000|Windows ME|Windows

NT|Windows 98|Windows 95"

row(5).Caption = "Error Code"

row(5).DataType = GetType(Integer)

row(6).Caption = "Resolved"

row(6).DataType = GetType(Boolean)

 

    C#

row[1].Caption = "Date";

row[1].DataType = typeof(DateTime);

row[2].Caption = "Contact";

row[2].DataType = typeof(string);

row[3].Caption = "Phone";

row[3].DataType = typeof(string);

row[3].EditMask = "(999)   999-9999;*";

row[4].Caption = "Platform";

row[4].DataType = typeof(string);

row[4].ComboList = "|Windows XP|Windows 2000|Windows ME|Windows

NT|Windows 98|Windows 95";

row[5].Caption = "Error      Code";

row[5].DataType = typeof(int);

row[6].Caption = "Resolved";

row[6].DataType = typeof(bool);

4.      将标题行的字体格式化为Tahoma, 9pt, Bold

    Visual Basic

Me.C1FlexGrid1.Styles("Fixed").Font = New Font("Tahoma", 9,

FontStyle.Bold)

                  

    C#

this.c1FlexGrid1.Styles["Fixed"].Font = new Font("Tahoma", 9,

FontStyle.Bold);

5.      合并固定行并添加标题行:

    Visual Basic

Me.C1FlexGrid1.AllowMerging =

C1.Win.C1FlexGrid.AllowMergingEnum.FixedOnly

row(0).AllowMerging = True

Dim rng As C1.Win.C1FlexGrid.CellRange = C1FlexGrid1.GetCellRange(0, 1,

0, 4)

rng.Data = "Call Log"

 

    C#

this.c1FlexGrid1.AllowMerging =

C1.Win.C1FlexGrid.AllowMergingEnum.FixedOnly;

row[0].AllowMerging = true;

C1.Win.C1FlexGrid.CellRange rng = c1FlexGrid1.GetCellRange(0,1,0,4);

rng.Data = "Call Log";

本主题演示如下:

标题行将会出现在第一列并且每一行将会被格式化为它自己拥有的DataType属性: