Bagikan melalui


DataGridViewComboBoxColumn.CellTemplate Properti

Definisi

Mendapatkan atau mengatur templat yang digunakan untuk membuat sel.

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

Nilai Properti

Bahwa DataGridViewCell semua sel lain dalam kolom dimodelkan setelahnya. Nilai defaultnya adalah baru DataGridViewComboBoxCell.

Atribut

Pengecualian

Saat mengatur properti ini ke nilai yang bukan tipe DataGridViewComboBoxCell.

Contoh

Contoh kode berikut menunjukkan penggunaan DataGridViewColumn.CellTemplate properti, yang mirip dengan properti ini. Contoh ini adalah bagian dari contoh yang lebih besar yang tersedia di Cara: Memanipulasi Kolom di Kontrol Windows Forms 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

Keterangan

Konstruktor untuk DataGridViewComboBoxColumn kelas menginisialisasi properti ini ke yang baru dibuat DataGridViewComboBoxCell.

Perhatian

Mengubah properti templat sel tidak akan segera memengaruhi antarmuka pengguna (UI) dari sel kolom yang ada. Perubahan ini hanya jelas setelah kolom diregenerasi (misalnya, dengan mengurutkan kolom atau melalui panggilan ke DataGridView.InvalidateColumn metode ).

Berlaku untuk

Lihat juga