DataGridViewCheckBoxColumn.CellTemplate Özellik

Tanım

Yeni hücreler oluşturmak için kullanılan şablonu alır veya ayarlar.

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

Özellik Değeri

DataGridViewCell

DataGridViewCell Sütundaki diğer tüm hücrelerin modellendiği bir. Varsayılan değer yeni DataGridViewCheckBoxCell bir örnektir.

Öznitelikler

Özel durumlar

özelliği türünde DataGridViewCheckBoxCellolmayan bir değere ayarlanır.

Örnekler

Aşağıdaki kod örneği, hangi çalışanların ofis dışında olduğunu işaretlemek için nasıl kullanılacağını DataGridViewCheckBoxColumn gösterir. Hücre şablonu, onay kutusu sütunundaki tüm hücrelere aynı rengi uygulamak için kullanılır. Bu örnek, sınıfa genel bakış konusunda bulunan DataGridViewComboBoxColumn daha büyük bir örneğin parçasıdır.

private:
    void AddOutOfOfficeColumn()
    {
        DataGridViewCheckBoxColumn^ column = gcnew DataGridViewCheckBoxColumn();
        {
            column->HeaderText = ColumnName::OutOfOffice.ToString();
            column->Name = ColumnName::OutOfOffice.ToString();
            column->AutoSizeMode = 
                DataGridViewAutoSizeColumnMode::DisplayedCells;
            column->FlatStyle = FlatStyle::Standard;
            column->ThreeState = true;
            column->CellTemplate = gcnew DataGridViewCheckBoxCell();
            column->CellTemplate->Style->BackColor = Color::Beige;
        }

        DataGridView1->Columns->Insert(0, column);
    }
private void AddOutOfOfficeColumn()
{
    DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn();
    {
        column.HeaderText = ColumnName.OutOfOffice.ToString();
        column.Name = ColumnName.OutOfOffice.ToString();
        column.AutoSizeMode = 
            DataGridViewAutoSizeColumnMode.DisplayedCells;
        column.FlatStyle = FlatStyle.Standard;
        column.ThreeState = true;
        column.CellTemplate = new DataGridViewCheckBoxCell();
        column.CellTemplate.Style.BackColor = Color.Beige;
    }

    DataGridView1.Columns.Insert(0, column);
}
Private Sub AddOutOfOfficeColumn()
    Dim column As New DataGridViewCheckBoxColumn()
    With column
        .HeaderText = ColumnName.OutOfOffice.ToString()
        .Name = ColumnName.OutOfOffice.ToString()
        .AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
        .FlatStyle = FlatStyle.Standard
        .CellTemplate = New DataGridViewCheckBoxCell()
        .CellTemplate.Style.BackColor = Color.Beige
    End With

    DataGridView1.Columns.Insert(0, column)
End Sub

Açıklamalar

sınıfının oluşturucuları DataGridViewCheckBoxColumn bu özelliği yeni oluşturulan DataGridViewCheckBoxCellbir ile başlatır.

Dikkat

Hücre şablonunun özelliklerini değiştirmek, sütunun mevcut hücrelerinin kullanıcı arabirimini (UI) hemen etkilemez. Bu değişiklikler yalnızca sütun yeniden üretildikten sonra görünür (örneğin, sütunu sıralayarak veya yöntemine DataGridView.InvalidateColumn yapılan bir çağrı aracılığıyla).

Şunlara uygulanır

Ayrıca bkz.