DataGridViewRowPostPaintEventArgs.InheritedRowStyle Propiedad

Definición

Obtiene el estilo de celda aplicado a la fila DataGridViewRow actual.

public:
 property System::Windows::Forms::DataGridViewCellStyle ^ InheritedRowStyle { System::Windows::Forms::DataGridViewCellStyle ^ get(); };
public System.Windows.Forms.DataGridViewCellStyle InheritedRowStyle { get; }
member this.InheritedRowStyle : System.Windows.Forms.DataGridViewCellStyle
Public ReadOnly Property InheritedRowStyle As DataGridViewCellStyle

Valor de propiedad

DataGridViewCellStyle que contiene el estilo de celda aplicado a la fila DataGridViewRow actual.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar InheritedRowStyle para determinar el color que se va a usar para dibujar el contenido. La variable , ees de tipo DataGridViewRowPostPaintEventArgs. Este ejemplo de código forma parte de un ejemplo más grande proporcionado en How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control.

// Determine the foreground color.
if ((e.State & DataGridViewElementStates.Selected) ==
    DataGridViewElementStates.Selected)
{
    forebrush = new SolidBrush(e.InheritedRowStyle.SelectionForeColor);
}
else
{
    forebrush = new SolidBrush(e.InheritedRowStyle.ForeColor);
}
' Determine the foreground color.
If (e.State And DataGridViewElementStates.Selected) = _
    DataGridViewElementStates.Selected Then

    forebrush = New SolidBrush(e.InheritedRowStyle.SelectionForeColor)
Else
    forebrush = New SolidBrush(e.InheritedRowStyle.ForeColor)
End If

Comentarios

La InheritedRowStyle propiedad contiene los mismos valores que la propiedad de InheritedStyle la fila actual. El acceso directo a un DataGridViewRow elemento en DataGridView puede afectar al rendimiento. Use InheritedRowStyle en el RowPostPaint evento para evitar el uso compartido de la fila y mantener un rendimiento óptimo.

La propiedad InheritedRowStyle es de sólo lectura. Aunque puede establecer las propiedades del recuperado a través de DataGridViewCellStyle la InheritedRowStyle propiedad , la nueva configuración no tendrá ningún efecto.

Se aplica a

Consulte también