DataGridViewColumn.HeaderText Vlastnost

Definice

Získá nebo nastaví popis text v buňce záhlaví sloupce.

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

Hodnota vlastnosti

A String s požadovaným textem. Výchozí hodnota je prázdný řetězec ("").

Příklady

Následující příklad kódu používá HeaderText vlastnost ke změně textu v záhlaví sloupce. Tento příklad kódu je součástí většího příkladu DataGridViewColumn pro třídu.

// 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

Poznámky

Tato vlastnost je užitečná pouze v případě, že má sloupec přidruženou buňku záhlaví. Další informace najdete ve HeaderCellCore vlastnosti.

Poznámka

Pro řádky neexistuje odpovídající vlastnost textu záhlaví. Pokud chcete zobrazit popisky v záhlaví řádků, musíte událost zpracovat DataGridView.CellPainting a nakreslit vlastní popisky, když DataGridViewCellPaintingEventArgs.ColumnIndex je hodnota -1.

Platí pro

Viz také