DataGridViewComboBoxColumn.CellTemplate プロパティ

定義

セルの作成に使用するテンプレートを取得または設定します。

public:
 virtual property System::Windows::Forms::DataGridViewCell ^ CellTemplate { System::Windows::Forms::DataGridViewCell ^ get(); void set(System::Windows::Forms::DataGridViewCell ^ value); };
[System.ComponentModel.Browsable(false)]
public override System.Windows.Forms.DataGridViewCell CellTemplate { get; set; }
[System.ComponentModel.Browsable(false)]
public override System.Windows.Forms.DataGridViewCell? CellTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.CellTemplate : System.Windows.Forms.DataGridViewCell with get, set
Public Overrides Property CellTemplate As DataGridViewCell

プロパティ値

列に含まれる他のすべてのセルがモデルとする DataGridViewCell。 既定値は新しい DataGridViewComboBoxCell です。

属性

例外

このプロパティが DataGridViewComboBoxCell 型でない値に設定されています。

次のコード例では、 プロパティの使用方法を DataGridViewColumn.CellTemplate 示します。これは、このプロパティに似ています。 この例は、「方法: Windows フォーム DataGridView コントロールの列を操作する」で使用できるより大きな例の一部です。

void CustomizeCellsInThirdColumn()
{
   int thirdColumn = 2;
   DataGridViewColumn^ column = dataGridView->Columns[ thirdColumn ];
   DataGridViewCell^ cell = gcnew DataGridViewTextBoxCell;
   cell->Style->BackColor = Color::Wheat;
   column->CellTemplate = cell;
}
private void CustomizeCellsInThirdColumn()
{
    int thirdColumn = 2;
    DataGridViewColumn column =
        dataGridView.Columns[thirdColumn];
    DataGridViewCell cell = new DataGridViewTextBoxCell();

    cell.Style.BackColor = Color.Wheat;
    column.CellTemplate = cell;
}
Private Sub CustomizeCellsInThirdColumn()

    Dim thirdColumn As Integer = 2
    Dim column As DataGridViewColumn = _
        dataGridView.Columns(thirdColumn)
    Dim cell As DataGridViewCell = _
        New DataGridViewTextBoxCell()

    cell.Style.BackColor = Color.Wheat
    column.CellTemplate = cell
End Sub

注釈

クラスのコンストラクターは、 DataGridViewComboBoxColumn このプロパティを新しく作成 DataGridViewComboBoxCellされた に初期化します。

注意事項

セル テンプレートのプロパティを変更すると、列の既存のセルのユーザー インターフェイス (UI) にすぐには影響しません。 これらの変更は、列が再生成された後 (たとえば、列の並べ替えやメソッドの DataGridView.InvalidateColumn 呼び出しによって) 明らかになります。

適用対象

こちらもご覧ください