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

특성

예외

집합 형식이 DataGridViewTextBoxCell 형식과 호환되지 않는 경우

예제

다음 코드 예제에서는 DataGridViewColumn.CellTemplate 속성을이 속성에 비슷합니다. 이 예제는에서 사용할 수 있는 보다 큰 예제의 일부 방법: Windows Forms DataGridView 컨트롤에서 열 조작합니다.

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

설명

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

주의

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

적용 대상

추가 정보