DataGridViewColumn.HeaderText 속성

정의

열의 머리글 셀에 있는 캡션 텍스트를 가져오거나 설정합니다.

public:
 property System::String ^ HeaderText { System::String ^ get(); void set(System::String ^ value); };
public string HeaderText { get; set; }
member this.HeaderText : string with get, set
Public Property HeaderText As String

속성 값

원하는 텍스트를 포함하는 String입니다. 기본값은 빈 문자열("")입니다.

예제

다음 코드 예제를 사용 합니다 HeaderText 속성을 열 머리글의 텍스트를 변경 합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 DataGridViewColumn 클래스입니다.

// Change the text in the column header.
void Button9_Click( Object^ /*sender*/, EventArgs^ /*args*/ )
{
   IEnumerator^ myEnum2 = dataGridView->Columns->GetEnumerator();
   while ( myEnum2->MoveNext() )
   {
      DataGridViewColumn^ column = safe_cast<DataGridViewColumn^>(myEnum2->Current);
      column->HeaderText = String::Concat( L"Column ", column->Index.ToString() );
   }
}
// Change the text in the column header.
private void Button9_Click(object sender,
    EventArgs args)
{
    foreach (DataGridViewColumn column in dataGridView.Columns)
    {

        column.HeaderText = String.Concat("Column ",
            column.Index.ToString());
    }
}
' Change the text in the column header.
Private Sub Button9_Click(ByVal sender As Object, _
    ByVal args As EventArgs) Handles Button9.Click

    For Each column As DataGridViewColumn _
        In dataGridView.Columns

        column.HeaderText = String.Concat("Column ", _
            column.Index.ToString)
    Next
End Sub

설명

이 속성은 열에 연결된 헤더 셀이 있는 경우에만 유용합니다. 자세한 내용은 HeaderCellCore 속성을 참조하세요.

참고

행에 해당하는 헤더 텍스트 속성이 없습니다. 행 머리글에 레이블을 표시하려면 이벤트를 처리 DataGridView.CellPainting 하고 가 -1일 때 DataGridViewCellPaintingEventArgs.ColumnIndex 고유한 레이블을 그려야 합니다.

적용 대상

추가 정보