DataGridViewTextBoxColumn.CellTemplate Vlastnost

Definice

Získá nebo nastaví šablonu použitou k modelování vzhledu buňky.

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)>]
member this.CellTemplate : System.Windows.Forms.DataGridViewCell with get, set
Public Overrides Property CellTemplate As DataGridViewCell

Hodnota vlastnosti

DataGridViewCell

Všechny DataGridViewCell ostatní buňky ve sloupci jsou modelovány po.

Atributy

Výjimky

Typ sady není kompatibilní s typem DataGridViewTextBoxCell.

Příklady

Následující příklad kódu ukazuje použití DataGridViewColumn.CellTemplate vlastnosti, která je podobná této vlastnosti. Tento příklad je součástí většího příkladu, který je k dispozici v části Postupy: Manipulace se sloupci v ovládacím prvku model Windows Forms 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

Poznámky

Konstruktor třídy DataGridViewTextBoxColumn inicializuje tuto vlastnost na nově vytvořený DataGridViewTextBoxCell.

Upozornění

Změna vlastností šablony buňky nebude mít okamžitě vliv na uživatelské rozhraní existujících buněk sloupce. Tyto změny se projeví až po opětovném vygenerování sloupce (například řazením sloupce nebo voláním DataGridView.InvalidateColumn metody).

Platí pro

Viz také