DataGridViewImageColumn.CellTemplate Egenskap

Definition

Hämtar eller anger mallen som används för att skapa nya celler.

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

Egenskapsvärde

A DataGridViewCell som alla andra celler i kolumnen modelleras efter.

Attribut

Undantag

Uppsättningstypen är inte kompatibel med typen DataGridViewImageCell.

Exempel

I följande kodexempel visas hur egenskapen används DataGridViewColumn.CellTemplate , vilket liknar den här egenskapen. Det här exemplet är en del av ett större exempel i How to: Manipulate Columns in the Windows Forms DataGridView Control.

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

Kommentarer

Konstruktorerna för DataGridViewImageColumn klassen initierar den här egenskapen till en nyligen skapad DataGridViewImageCell.

Caution

Om du ändrar egenskaperna för cellmallen påverkas inte omedelbart användargränssnittet (UI) för kolumnens befintliga celler. Dessa ändringar visas bara när kolumnen har återskapats (till exempel genom att sortera kolumnen eller genom ett anrop till DataGridView.InvalidateColumn metoden).

Gäller för

Se även