True DBGrid for WinForms
基本的な操作
> 基本的な操作

This topic discusses about the various basic operations that can be performed on a column in True DBGrid.

Insert Column

True DBGrid lets you add a new column at the specified index using the Insert method of C1DataColumnCollection class.

C#
コードのコピー
C1.Win.TrueDBGrid.C1DataColumn Col = new C1.Win.TrueDBGrid.C1DataColumn();
C1.Win.TrueDBGrid.C1DisplayColumn dc;
c1TruedbGrid1.Columns.Insert(0, Col);
var colName = "Unbound" + c1TruedbGrid1.Columns.Count;
Col.Caption = colName;
dc = c1TruedbGrid1.Splits[0].DisplayColumns[colName];
// 新しく追加した列をグリッドの左端の位置に移動します。
c1TruedbGrid1.Splits[0].DisplayColumns.RemoveAt(c1TruedbGrid1.Splits[0].DisplayColumns.IndexOf(dc));
c1TruedbGrid1.Splits[0].DisplayColumns.Insert(c1TruedbGrid1.Col, dc);
dc.Visible = true;
c1TruedbGrid1.Rebind(true);

Delete Column

To delete a particular column from the grid, you can use the RemoveAt method of the C1DataColumnCollection class

C#
コードのコピー
if (c1TruedbGrid1.Columns.Count > 0)
    c1TruedbGrid1.Columns.RemoveAt(c1TruedbGrid1.Col);

Set Data Type

True DBGrid lets you set the data type of an unbound column in WinForms True DBGrid using the DataType property of the C1DataColumn class as shown in the code below.

C#
コードのコピー
// 列のデータ型を設定します[非連結モードでのみ機能します]
c1TruedbGrid1.Columns[0].DataType = typeof(string);

Set Frozen Column

Frozen columns, similar to fixed columns, are non-scrollable but can be edited by the user. In True DBGrid, frozen columns can be set by using Frozen property provided by the C1DisplayColumn class.

To set frozen columns in the WinForms True DBGrid, use the code below.

C#
コードのコピー
this.c1TruedbGrid1.Splits[0].DisplayColumns[1].Frozen = true;