DataGridViewImageColumn.CellTemplate Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Obtient ou définit le modèle utilisé pour créer de nouvelles 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)]
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é
Toutes DataGridViewCell les autres cellules de la colonne sont modélisées après.
- Attributs
Exceptions
Le type set n’est pas compatible avec le type DataGridViewImageCell.
Exemples
L’exemple de code suivant illustre l’utilisation de la DataGridViewColumn.CellTemplate propriété, qui est 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
Les constructeurs de la DataGridViewImageColumn classe initialisent cette propriété à un nouveau .DataGridViewImageCell
Avertissement
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 ne sont apparentes qu’une fois la colonne régénérée (par exemple, en triant la colonne ou via un appel à la DataGridView.InvalidateColumn méthode).