Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Propiedad DataGridView.ColumnHeadersBorderStyle

 

Publicado: octubre de 2016

Obtiene el estilo de borde aplicado a los encabezados de columna.

Espacio de nombres:   System.Windows.Forms
Ensamblado:  System.Windows.Forms (en System.Windows.Forms.dll)

[BrowsableAttribute(true)]
public DataGridViewHeaderBorderStyle ColumnHeadersBorderStyle { get; set; }

Exception Condition
InvalidEnumArgumentException

El valor especificado al establecer esta propiedad no es un valor de DataGridViewHeaderBorderStyle válido.

ArgumentException

El valor especificado al establecer esta propiedad es Custom.

If the P:System.Windows.Forms.DataGridView.ColumnHeadersBorderStyle property is set to anything other than F:System.Windows.Forms.DataGridViewHeaderBorderStyle.Single, the P:System.Windows.Forms.DataGridView.GridColor property must be a system color.

You cannot set this property to the F:System.Windows.Forms.DataGridViewHeaderBorderStyle.Custom value, which is a read-only value indicating that the border style has been customized through the use of the P:System.Windows.Forms.DataGridView.AdvancedColumnHeadersBorderStyle property.

System_CAPS_noteNota

If visual styles are enabled for the application through the M:System.Windows.Forms.Application.EnableVisualStyles method and the P:System.Windows.Forms.DataGridView.EnableHeadersVisualStyles property is true, the column headers are painted using the current theme. In this case, the value of the P:System.Windows.Forms.DataGridView.ColumnHeadersBorderStyle property is ignored for all column headers except the P:System.Windows.Forms.DataGridView.TopLeftHeaderCell, to which the theme is not applied.

The following code example demonstrates how to set the P:System.Windows.Forms.DataGridView.ColumnHeadersDefaultCellStyle, P:System.Windows.Forms.DataGridView.AutoSizeRowsMode, P:System.Windows.Forms.DataGridView.ColumnHeadersBorderStyle, P:System.Windows.Forms.DataGridView.CellBorderStyle, P:System.Windows.Forms.DataGridView.GridColor, P:System.Windows.Forms.DataGridView.BackgroundColor, P:System.Windows.Forms.DataGridView.RowHeadersVisible, P:System.Windows.Forms.DataGridView.SelectionMode, P:System.Windows.Forms.DataGridView.ColumnCount, and P:System.Windows.Forms.DataGridView.MultiSelect properties. In addition, the code example demonstrates how to set the P:System.Windows.Forms.DataGridViewColumn.Name and P:System.Windows.Forms.DataGridViewColumn.DefaultCellStyle properties. To run this example, paste the code into a form that contains a T:System.Windows.Forms.DataGridView nameddataGridView1, and then call the SetUpDataGridView method from the form's constructor or E:System.Windows.Forms.Form.Load event handler. Ensure all events are associated with their event handlers.

private void SetUpDataGridView()
{
    this.Controls.Add(dataGridView1);
    dataGridView1.ColumnCount = 5;
    DataGridViewCellStyle style = 
        dataGridView1.ColumnHeadersDefaultCellStyle;
    style.BackColor = Color.Navy;
    style.ForeColor = Color.White;
    style.Font = new Font(dataGridView1.Font, FontStyle.Bold);

    dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
    dataGridView1.Name = "dataGridView1";
    dataGridView1.Location = new Point(8, 8);
    dataGridView1.Size = new Size(500, 300);
    dataGridView1.AutoSizeRowsMode = 
        DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
    dataGridView1.ColumnHeadersBorderStyle = 
        DataGridViewHeaderBorderStyle.Raised;
    dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.Single;
    dataGridView1.GridColor = SystemColors.ActiveBorder;
    dataGridView1.RowHeadersVisible = false;

    dataGridView1.Columns[0].Name = "Release Date";
    dataGridView1.Columns[1].Name = "Track";
    dataGridView1.Columns[1].DefaultCellStyle.Alignment = 
        DataGridViewContentAlignment.MiddleCenter;
    dataGridView1.Columns[2].Name = "Title";
    dataGridView1.Columns[3].Name = "Artist";
    dataGridView1.Columns[4].Name = "Album";

    // Make the font italic for row four.
    dataGridView1.Columns[4].DefaultCellStyle.Font = new Font(DataGridView.DefaultFont, FontStyle.Italic);

    dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    dataGridView1.MultiSelect = false;

    dataGridView1.BackgroundColor = Color.Honeydew;

    dataGridView1.Dock = DockStyle.Fill;

    dataGridView1.CellFormatting += new DataGridViewCellFormattingEventHandler(dataGridView1_CellFormatting);
    dataGridView1.CellParsing += new DataGridViewCellParsingEventHandler(dataGridView1_CellParsing);
    addNewRowButton.Click += new EventHandler(addNewRowButton_Click);
    deleteRowButton.Click += new EventHandler(deleteRowButton_Click);
    ledgerStyleButton.Click += new EventHandler(ledgerStyleButton_Click);
    dataGridView1.CellValidating += new DataGridViewCellValidatingEventHandler(dataGridView1_CellValidating);

}

.NET Framework
Disponible desde 2.0
Volver al principio
Mostrar: