DataGridViewCheckBoxColumn.CellTemplate 속성

정의

셀을 새로 만드는 데 사용되는 템플릿을 가져오거나 설정합니다.

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

속성 값

DataGridViewCell

열에 있는 다른 모든 셀의 모델이 되는 DataGridViewCell입니다. 기본값은 새 DataGridViewCheckBoxCell 인스턴스입니다.

특성

예외

DataGridViewCheckBoxCell 형식이 아닌 값으로 속성이 설정된 경우

예제

다음 코드 예제에서는 어떤 직원이 사무실 외부에 있는지 표시하는 데 사용하는 DataGridViewCheckBoxColumn 방법을 보여 줍니다. 셀 서식 파일은 확인란 열의 모든 셀에 동일한 색을 적용하는 데 사용됩니다. 이 예제는에서 사용할 수 있는 보다 큰 예제의 일부는 DataGridViewComboBoxColumn 클래스 개요 항목입니다.

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

설명

클래스의 DataGridViewCheckBoxColumn 생성자는 이 속성을 새로 만든 DataGridViewCheckBoxCell속성으로 초기화합니다.

주의

셀 템플릿의 속성을 변경 해도 열의 기존 셀의 사용자 인터페이스 (UI) 즉시 영향을 주지 않습니다. 열 다시 생성 된 후에 이러한 변경 사항은 명백한만 (예를 들어 열을 정렬 하거나 호출을 통해는 DataGridView.InvalidateColumn 메서드).

적용 대상

추가 정보