DataGridViewLinkColumn.CellTemplate Vlastnost

Definice

Získá nebo nastaví šablonu použitou k vytvoření nových buněk.

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. Výchozí hodnota je nová DataGridViewLinkCell instance.

Atributy

Výjimky

Při nastavení této vlastnosti na hodnotu, která není typu DataGridViewLinkCell.

Příklady

Následující příklad kódu ukazuje, jak použít DataGridViewCell jako šablonu pro DataGridViewColumn. Změny stylu provedené v libovolné buňce ve sloupci ovlivňují všechny buňky sloupce. Tento příklad kódu je součástí většího příkladu zadaného DataGridViewColumn pro třídu.

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 DataGridViewLinkColumn inicializuje tuto vlastnost na nově vytvořenou DataGridViewLinkCell.

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é