DataGridViewImageColumn.DefaultCellStyle 속성

정의

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

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

속성 값

기본 스타일로 적용할 DataGridViewCellStyle 입니다.

특성

예제

다음 코드 예제에서는이 속성을 사용 하는 방법을 보여 줍니다.

private void ChangeColumnAlignment()
{
    songsDataGridView.Columns["Title"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter;
    songsDataGridView.Columns["Title"].Name = DataGridViewContentAlignment.BottomCenter.ToString();

    songsDataGridView.Columns["Artist"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft;
    songsDataGridView.Columns["Artist"].Name = DataGridViewContentAlignment.BottomLeft.ToString();

    songsDataGridView.Columns["Album"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight;
    songsDataGridView.Columns["Album"].Name = DataGridViewContentAlignment.BottomRight.ToString();

    songsDataGridView.Columns["Release Date"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
    songsDataGridView.Columns["Release Date"].Name = DataGridViewContentAlignment.MiddleCenter.ToString();

    songsDataGridView.Columns["Track"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
    songsDataGridView.Columns["Track"].Name = DataGridViewContentAlignment.MiddleLeft.ToString();
}
Private Sub ChangeColumnAlignment()
    songsDataGridView.Columns("Title").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomCenter
    songsDataGridView.Columns("Title").Name = DataGridViewContentAlignment.BottomCenter.ToString()

    songsDataGridView.Columns("Artist").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomLeft
    songsDataGridView.Columns("Artist").Name = DataGridViewContentAlignment.BottomLeft.ToString()

    songsDataGridView.Columns("Album").DefaultCellStyle.Alignment = DataGridViewContentAlignment.BottomRight
    songsDataGridView.Columns("Album").Name = DataGridViewContentAlignment.BottomRight.ToString()

    songsDataGridView.Columns("Release Date").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
    songsDataGridView.Columns("Release Date").Name = DataGridViewContentAlignment.MiddleCenter.ToString()

    songsDataGridView.Columns("Track").DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
    songsDataGridView.Columns("Track").Name = DataGridViewContentAlignment.MiddleLeft.ToString()
End Sub

설명

이 속성에서 반환되는 기본값 DataGridViewCellStyle 에는 다음과 같은 초기 속성 값이 있습니다.

DataGridViewCellStyle 속성 기본값
Alignment DataGridViewContentAlignment.MiddleCenter
NullValue 초기 ValuesAreIcons 속성 값이 이면 형식 Icon 의 표준 오류 그래픽이고, 그렇지 않으면 형식Bitmap의 표준 오류 그래픽입니다true.

이러한 값은 컨트롤의 속성에 DefaultCellStyle 지정된 값을 재정의하지만 다른 셀 스타일 속성에 의해 재정의 DataGridView 될 수 있습니다. 자세한 내용은 Windows Forms DataGridView 컨트롤의 셀 스타일을 참조하세요.

또는 셀 값에 대해 nullDBNull.Value 표준 오류 그래픽이 나타나지 않도록 하려면 컨트롤에 행을 추가하기 전에 이 셀 스타일 개체 null 의 속성을 또는 사용자 고유의 오류 그래픽으로 설정합니다DataGridViewCellStyle.NullValue. 그러나 새 레코드의 행에는 영향을 주지 않습니다. 컨트롤 속성 값이 일 때 새 레코드에 대한 행에 오류 그래픽이 true나타나지 않도록 하려면 컨트롤 AllowUserToAddRows 이벤트에 대한 RowsAdded 처리기에서 셀 값을 null 명시적으로 로 설정하거나 열 속성을 반환하는 재정 DefaultNewRowValue 의된 속성 null 또는 고유한 오류 그래픽이 있는 파생 형식의 DataGridViewImageCellinstance 설정 CellTemplate 해야 합니다.

속성에서 NullValue 반환된 DefaultCellStyle 개체의 속성에 형식Bitmap의 표준 오류 그래픽과 같은 값이 있는 경우 속성 값을 형식의 Icon표준 오류 그래픽으로 자동으로 설정 NullValue 하도록 true 변경 ValuesAreIcons 합니다. 값이 형식Icon의 표준 오류 그래픽과 같은 경우 NullValue 속성 값을 형식의 표준 오류 그래픽Bitmap으로 자동으로 설정 NullValue 하도록 false 변경 ValuesAreIcons 합니다.

적용 대상

추가 정보