DataGridViewImageColumn.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)]
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

Wszystkie DataGridViewCell pozostałe komórki w kolumnie są modelowane po.

Atrybuty

Wyjątki

Typ zestawu nie jest zgodny z typem DataGridViewImageCell.

Przykłady

Poniższy przykład kodu przedstawia użycie DataGridViewColumn.CellTemplate właściwości podobnej do tej właściwości. Ten przykład jest częścią większego przykładu dostępnego w temacie How to: Manipulate Columns in the Windows Forms DataGridView Control (Manipulowanie kolumnami w kontrolce 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

Uwagi

Konstruktory klasy inicjują DataGridViewImageColumn tę właściwość do nowo utworzonego DataGridViewImageCellobiektu .

Przestroga

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

Dotyczy

Zobacz też