DataGridViewCell.Style 속성

정의

셀의 스타일을 가져오거나 설정합니다.

public:
 property System::Windows::Forms::DataGridViewCellStyle ^ Style { System::Windows::Forms::DataGridViewCellStyle ^ get(); void set(System::Windows::Forms::DataGridViewCellStyle ^ value); };
[System.ComponentModel.Browsable(true)]
public System.Windows.Forms.DataGridViewCellStyle Style { get; set; }
[<System.ComponentModel.Browsable(true)>]
member this.Style : System.Windows.Forms.DataGridViewCellStyle with get, set
Public Property Style As DataGridViewCellStyle

속성 값

DataGridViewCellStyle

셀과 연결된 스타일입니다.

특성

예제

다음 코드 예제에서는 셀의 배경색을 Style 가져오기 위해 속성을 사용 하는 방법을 보여 줍니다. 이 예제는 클래스에 제공된 더 큰 코드 예제의 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

설명

컨트롤은 DataGridView 형식DataGridViewCellStyle의 다른 속성에서 스타일을 상속하는 셀 속성으로 표시된 스타일을 사용하여 해당 셀 InheritedStyle 을 표시합니다. 속성을 통해 Style 지정된 스타일은 다른 모든 셀 스타일 속성을 통해 지정된 스타일을 재정의하지만 셀의 모양에 영향을 주는 모든 스타일을 반드시 나타내는 것은 아닙니다.

자세한 내용은 Windows Forms DataGridView 컨트롤의 셀 스타일을 참조하세요.

적용 대상

추가 정보