DataGridViewComboBoxColumn.CellTemplate Propriété

Définition

Obtient ou définit le modèle utilisé pour créer des cellules.

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

Valeur de propriété

DataGridViewCell

DataGridViewCell d'après lequel toutes les autres cellules de la colonne sont modelées. La valeur par défaut est un nouveau DataGridViewComboBoxCell.

Attributs

Exceptions

Lors de l'affectation d'une valeur qui n'est pas de type DataGridViewComboBoxCell à cette propriété.

Exemples

L’exemple de code suivant illustre l’utilisation de la DataGridViewColumn.CellTemplate propriété, similaire à cette propriété. Cet exemple fait partie d’un exemple plus large disponible dans 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

Remarques

Le constructeur de la DataGridViewComboBoxColumn classe initialise cette propriété à une nouvelle création DataGridViewComboBoxCell.

Attention

La modification des propriétés du modèle de cellule n’affecte pas immédiatement l’interface utilisateur des cellules existantes de la colonne. Ces modifications sont visibles uniquement une fois la colonne régénérée (par exemple, en triant la colonne ou via un appel à la DataGridView.InvalidateColumn méthode).

S’applique à

Voir aussi