Olvasás angol nyelven Szerkesztés

Megosztás a következőn keresztül:


DataGridViewColumn.HeaderCell Property

Definition

Gets or sets the DataGridViewColumnHeaderCell that represents the column header.

[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.DataGridViewColumnHeaderCell HeaderCell { get; set; }

Property Value

A DataGridViewColumnHeaderCell that represents the header cell for the column.

Attributes

Examples

The following code example uses the HeaderCell property to change column header style and contents.

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

Remarks

The header of a column is typically used to display a column label. Depending on the current values of the SortMode and DataGridView.SelectionMode properties, users can also click the column header to sort or select the column.

Applies to

Termék Verziók
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also