GcComboBoxCellのリストボックスでは、ヘッダと項目に複数のカラム(列)を持つことができます。表示できるカラム数に制限はありません。
カラムを設定するには、ListColumnsプロパティが参照するListColumnCollectionクラスを使用します。ListColumnCollectionクラスは、リストの個々のカラムを表すListColumnオブジェクトを保持するコレクションです。
ListColumnオブジェクトは、主に次のプロパティを設定でき、カラムごとに異なるスタイルや動作を適用できます。
また、カラムのインデックスを下記のプロパティに設定することで、それぞれの目的でサブ項目を使用できます。
コードによる設定
コードからカラムを追加するには、ListColumnCollectionのAddメソッドまたはAddRangeメソッドを使用します。
次のコードは、Addメソッドを使用してカラムを1つ追加するサンプルコードです。ここではカラムの名前(ヘッダに表示されるテキスト)を指定してカラムを追加しています。
Imports GrapeCity.Win.MultiRow
Imports InputManCell = GrapeCity.Win.MultiRow.InputMan
Dim GcComboBoxCell1 = New InputManCell.GcComboBoxCell()
GcComboBoxCell1.ListColumns.Add(New InputManCell.ListColumn("カラム1"))
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {GcComboBoxCell1})
using GrapeCity.Win.MultiRow;
using InputManCell = GrapeCity.Win.MultiRow.InputMan;
InputManCell.GcComboBoxCell gcComboBoxCell1 = new InputManCell.GcComboBoxCell();
gcComboBoxCell1.ListColumns.Add(new InputManCell.ListColumn("カラム1"));
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { gcComboBoxCell1 });
カラムを削除するには、ListColumnCollectionのRemoveメソッドまたはRemoveAtメソッドを使用します。
次のコードは、RemoveAtメソッドを使用して先頭のカラムを1つ削除するサンプルコードです。
このサンプルでは、テンプレートのRowセクションに[gcComboBoxCell1]が配置されていることを前提とします。
Imports InputManCell = GrapeCity.Win.MultiRow.InputMan
Dim GcComboBoxCell As InputManCell.GcComboBoxCell = DirectCast(GcMultiRow1.CurrentRow.Cells("GcComboBoxCell1"), InputManCell.GcComboBoxCell)
GcComboBoxCell.ListColumns.RemoveAt(0)
using InputManCell = GrapeCity.Win.MultiRow.InputMan;
InputManCell.GcComboBoxCell gcComboBoxCell = (InputManCell.GcComboBoxCell)gcMultiRow1.CurrentRow.Cells["gcComboBoxCell1"];
gcComboBoxCell.ListColumns.RemoveAt(0);
デザイン画面での設定
デザイン画面ではカラムの追加や削除を行える「カラムの編集」エディタから容易な設定が可能です。 このエディタは次のいずれかの方法で起動できます。
- セルのスマート タグから「カラムの編集...」を選択
- プロパティウィンドウのListColumnsプロパティをアクティブした時に表示される「…」ボタンを押下
また、スマート タグの「カラムの追加」をクリックすると、カラムが一つ追加されます。
セルのListDefaultColumnプロパティが参照するDefaultListColumnオブジェクトを使用すると、 追加したカラムに既定値を設定することができます。カラムの既定値の設定は、繰り返し設定を変更する手間を省略でき、データソース接続をするとき、AutoGenerateColumnsプロパティがTrueで、自動的にカラムを追加する場合などに便利な機能です。
次のサンプルコードは、カラムの既定値を設定する例です。
Imports GrapeCity.Win.MultiRow
Imports InputManCell = GrapeCity.Win.MultiRow.InputMan
Dim GcComboBoxCell1 = New InputManCell.GcComboBoxCell()
GcComboBoxCell1.ListDefaultColumn.AutoWidth = True
GcComboBoxCell1.ListDefaultColumn.Header.AllowResize = True
GcComboBoxCell1.ListDefaultColumn.DefaultSubItem.ContentAlignment = ContentAlignment.MiddleRight
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() {GcComboBoxCell1})
using GrapeCity.Win.MultiRow;
using InputManCell = GrapeCity.Win.MultiRow.InputMan;
InputManCell.GcComboBoxCell gcComboBoxCell1 = new InputManCell.GcComboBoxCell();
gcComboBoxCell1.ListDefaultColumn.AutoWidth = true;
gcComboBoxCell1.ListDefaultColumn.Header.AllowResize = true;
gcComboBoxCell1.ListDefaultColumn.DefaultSubItem.ContentAlignment = ContentAlignment.MiddleRight;
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { gcComboBoxCell1 });
また、デザイン画面ではカラムの既定値を容易に設定できる行える「カラムの既定値の設定」エディタが用意されており、このエディタは次のいずれかの方法で起動できます。
- セルのスマート タグから「カラムの既定値を設定...」を選択
- プロパティウィンドウのListDefaultColumnsプロパティをアクティブした時に表示される「…」ボタンを押下