DataGridViewCheckBoxColumn.CellTemplate プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As DataGridViewCheckBoxColumn Dim value As DataGridViewCell value = instance.CellTemplate instance.CellTemplate = value
public: virtual property DataGridViewCell^ CellTemplate { DataGridViewCell^ get () override; void set (DataGridViewCell^ value) override; }
/** @property */ public DataGridViewCell get_CellTemplate () /** @property */ public void set_CellTemplate (DataGridViewCell value)
public override function get CellTemplate () : DataGridViewCell public override function set CellTemplate (value : DataGridViewCell)
列に含まれる他のすべてのセルがモデルとする DataGridViewCell。既定値は DataGridViewCheckBoxCell の新しいインスタンスです。


DataGridViewCheckBoxColumn クラスのコンストラクタは、このプロパティを新しく作成された DataGridViewCheckBoxCell に初期化します。
![]() |
---|
セル テンプレートのプロパティを変更しても、列の既存のセルのユーザー インターフェイス (UI) に直ちに反映されることはありません。この変更は、列が再生成されたとき (列を並べ替えたり DataGridView.InvalidateColumn メソッドを呼び出したりした場合など) に、初めて反映されます。 |

次のコード例は、DataGridViewCheckBoxColumn を使用して、外出している従業員をマークする方法を示しています。セル テンプレートを使用して、チェック ボックス列に含まれるすべてのセルに同じ色を適用しています。
Private Sub AddOutOfOfficeColumn() Dim column As New DataGridViewCheckBoxColumn() With column .HeaderText = ColumnName.OutOfOffice.ToString() .Name = ColumnName.OutOfOffice.ToString() .AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells .FlatStyle = FlatStyle.Standard .CellTemplate = New DataGridViewCheckBoxCell() .CellTemplate.Style.BackColor = Color.Beige End With DataGridView1.Columns.Insert(0, column) End Sub
private void AddOutOfOfficeColumn() { DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn(); { column.HeaderText = ColumnName.OutOfOffice.ToString(); column.Name = ColumnName.OutOfOffice.ToString(); column.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; column.FlatStyle = FlatStyle.Standard; column.ThreeState = true; column.CellTemplate = new DataGridViewCheckBoxCell(); column.CellTemplate.Style.BackColor = Color.Beige; } DataGridView1.Columns.Insert(0, column); }
private: void AddOutOfOfficeColumn() { DataGridViewCheckBoxColumn^ column = gcnew DataGridViewCheckBoxColumn(); { column->HeaderText = ColumnName::OutOfOffice.ToString(); column->Name = ColumnName::OutOfOffice.ToString(); column->AutoSizeMode = DataGridViewAutoSizeColumnMode::DisplayedCells; column->FlatStyle = FlatStyle::Standard; column->ThreeState = true; column->CellTemplate = gcnew DataGridViewCheckBoxCell(); column->CellTemplate->Style->BackColor = Color::Beige; } DataGridView1->Columns->Insert(0, column); }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataGridViewCheckBoxColumn.CellTemplate プロパティのページへのリンク