DataGridViewButtonColumn.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입니다.

특성

예외

이 속성을 설정할 때 지정한 값을 DataGridViewButtonCell로 캐스팅할 수 없는 경우

예제

다음 코드 예제에서는 직원이 만든 매출을 보기 위해 a DataGridViewButtonColumn 를 사용하는 방법을 보여 줍니다. 셀 서식 파일은 모든 단추에 동일한 색을 적용하는 데 사용됩니다. 이 예제는에서 사용할 수 있는 보다 큰 예제의 일부는 DataGridViewComboBoxColumn 클래스 개요 항목입니다.

private:
    void AddButtonColumn()
    {
        DataGridViewButtonColumn^ buttons = gcnew DataGridViewButtonColumn();
        {
            buttons->HeaderText = "Sales";
            buttons->Text = "Sales";
            buttons->UseColumnTextForButtonValue = true;
            buttons->AutoSizeMode =
                DataGridViewAutoSizeColumnMode::AllCells;
            buttons->FlatStyle = FlatStyle::Standard;
            buttons->CellTemplate->Style->BackColor = Color::Honeydew;
            buttons->DisplayIndex = 0;
        }

        DataGridView1->Columns->Add(buttons);

    }
private void AddButtonColumn()
{
    DataGridViewButtonColumn buttons = new DataGridViewButtonColumn();
    {
        buttons.HeaderText = "Sales";
        buttons.Text = "Sales";
        buttons.UseColumnTextForButtonValue = true;
        buttons.AutoSizeMode =
            DataGridViewAutoSizeColumnMode.AllCells;
        buttons.FlatStyle = FlatStyle.Standard;
        buttons.CellTemplate.Style.BackColor = Color.Honeydew;
        buttons.DisplayIndex = 0;
    }

    DataGridView1.Columns.Add(buttons);
}
Private Sub AddButtonColumn()
    Dim buttons As New DataGridViewButtonColumn()
    With buttons
        .HeaderText = "Sales"
        .Text = "Sales"
        .UseColumnTextForButtonValue = True
        .AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells
        .FlatStyle = FlatStyle.Standard
        .CellTemplate.Style.BackColor = Color.Honeydew
        .DisplayIndex = 0
    End With

    DataGridView1.Columns.Add(buttons)

End Sub

설명

에 대 한 생성자는 DataGridViewButtonColumn 클래스를 새로 만든이 속성을 초기화 DataGridViewButtonCell합니다.

주의

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

적용 대상

추가 정보