DataGridViewColumn.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 virtual System.Windows.Forms.DataGridViewCell CellTemplate { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.CellTemplate : System.Windows.Forms.DataGridViewCell with get, set
Public Overridable Property CellTemplate As DataGridViewCell

속성 값

DataGridViewCell

열에 있는 다른 모든 셀의 모델이 되는 DataGridViewCell입니다. 기본값은 null입니다.

특성

예제

다음 코드 예제를 사용 하는 방법에 설명 된 DataGridViewCell 에 대 한 템플릿으로 DataGridViewColumn합니다. 열의 모든 셀에 대 한 스타일 변경에 열의 셀을 모두 영향을 줍니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 DataGridViewColumn 클래스입니다.

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

설명

클래스의 DataGridViewColumn 생성자는 이 속성을 초기화합니다. 매개 변수가 없는 생성자는 속성을 설정하며 null다른 생성자는 해당 매개 변수에서 셀 템플릿을 복사합니다.

참고

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

적용 대상

추가 정보