DataGridViewLinkColumn.CellTemplate Właściwość

Definicja

Pobiera lub ustawia szablon używany do tworzenia nowych komórek.

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

Wartość właściwości

DataGridViewCell

Wszystkie DataGridViewCell pozostałe komórki w kolumnie są modelowane po. Wartość domyślna to nowe DataGridViewLinkCell wystąpienie.

Atrybuty

Wyjątki

Podczas ustawiania tej właściwości na wartość, która nie jest typu DataGridViewLinkCell.

Przykłady

W poniższym przykładzie kodu pokazano, jak używać elementu DataGridViewCell jako szablonu dla elementu DataGridViewColumn. Zmiany stylu wprowadzone w dowolnej komórce w kolumnie wpływają na wszystkie komórki kolumny. Ten przykład kodu jest częścią większego przykładu udostępnionego DataGridViewColumn dla klasy .

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

Uwagi

Konstruktor klasy inicjuje DataGridViewLinkColumn tę właściwość do nowo utworzonego obiektu DataGridViewLinkCell.

Przestroga

Zmiana właściwości szablonu komórki nie wpłynie natychmiast na interfejs użytkownika (UI) istniejących komórek kolumny. Te zmiany są widoczne tylko po wygenerowaniu kolumny (na przykład przez posortowanie kolumny lub wywołanie DataGridView.InvalidateColumn metody).

Dotyczy

Zobacz też