DataGridViewRowPostPaintEventArgs.State Propiedad

Definición

Obtiene el estado de la celda DataGridViewRow actual.

public:
 property System::Windows::Forms::DataGridViewElementStates State { System::Windows::Forms::DataGridViewElementStates get(); };
public System.Windows.Forms.DataGridViewElementStates State { get; }
member this.State : System.Windows.Forms.DataGridViewElementStates
Public ReadOnly Property State As DataGridViewElementStates

Valor de propiedad

Combinación bit a bit de valores de DataGridViewElementStates que especifica el estado de la fila.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la State propiedad para determinar si está seleccionada la fila actual. La variable, e, es de tipo DataGridViewRowPostPaintEventArgs. Este ejemplo de código forma parte de un ejemplo más grande que se proporciona 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

Esta propiedad se puede usar para determinar si la fila está inmovilizada, de solo lectura o seleccionada, entre otros estados.

Se aplica a

Consulte también