Bahasa

DataGridViewLinkColumn.CellTemplate Properti

Definisi

Mendapatkan atau mengatur templat yang digunakan untuk membuat sel baru.

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 instans baru DataGridViewLinkCell .

Atribut

Pengecualian

Saat mengatur properti ini ke nilai yang bukan tipe DataGridViewLinkCell.

Contoh

Contoh kode berikut menunjukkan cara menggunakan DataGridViewCell sebagai templat untuk DataGridViewColumn. Perubahan gaya yang dibuat pada sel mana pun dalam kolom memengaruhi semua sel kolom. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk DataGridViewColumn kelas .

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 DataGridViewLinkColumn kelas menginisialisasi properti ini ke yang baru dibuat DataGridViewLinkCell.

Caution

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