DataGridViewColumn.HeaderCell 속성

정의

열 머리글을 나타내는 DataGridViewColumnHeaderCell을 가져오거나 설정합니다.

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

속성 값

DataGridViewColumnHeaderCell

열의 머리글 셀을 나타내는 DataGridViewColumnHeaderCell입니다.

특성

예제

다음 코드 예제에서는 속성을 사용 하 여 HeaderCell 열 머리글 스타일 및 내용을 변경 합니다.

// Style and number columns.
void Button8_Click( Object^ /*sender*/, EventArgs^ /*args*/ )
{
   DataGridViewCellStyle^ style = gcnew DataGridViewCellStyle;
   style->Alignment = DataGridViewContentAlignment::MiddleCenter;
   style->ForeColor = Color::IndianRed;
   style->BackColor = Color::Ivory;
   IEnumerator^ myEnum1 = dataGridView->Columns->GetEnumerator();
   while ( myEnum1->MoveNext() )
   {
      DataGridViewColumn^ column = safe_cast<DataGridViewColumn^>(myEnum1->Current);
      column->HeaderCell->Value = column->Index.ToString();
      column->HeaderCell->Style = style;
   }
}
// Style and number columns.
private void Button8_Click(object sender,
    EventArgs args)
{
    DataGridViewCellStyle style = new DataGridViewCellStyle();
    style.Alignment =
        DataGridViewContentAlignment.MiddleCenter;
    style.ForeColor = Color.IndianRed;
    style.BackColor = Color.Ivory;

    foreach (DataGridViewColumn column in dataGridView.Columns)
    {
        column.HeaderCell.Value = column.Index.ToString();
        column.HeaderCell.Style = style;
    }
}
' Style and number columns.
Private Sub Button8_Click(ByVal sender As Object, _
    ByVal args As EventArgs) Handles Button8.Click

    Dim style As DataGridViewCellStyle = _
        New DataGridViewCellStyle()
    style.Alignment = _
        DataGridViewContentAlignment.MiddleCenter
    style.ForeColor = Color.IndianRed
    style.BackColor = Color.Ivory

    For Each column As DataGridViewColumn _
        In dataGridView.Columns

        column.HeaderCell.Value = _
            column.Index.ToString
        column.HeaderCell.Style = style
    Next
End Sub

설명

열의 헤더는 일반적으로 열 레이블을 표시하는 데 사용됩니다. 현재 값 SortModeDataGridView.SelectionMode 속성에 따라 사용자는 열 머리글을 클릭하여 열을 정렬하거나 선택할 수도 있습니다.

적용 대상

추가 정보