Expandir Minimizar
Este tema aún no ha recibido ninguna valoración - Valorar este tema

DataGridView.IsCurrentCellDirty (Propiedad)

Obtiene un valor que indica si la celda actual tiene cambios sin confirmar.

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

public bool IsCurrentCellDirty { get; }
/** @property */
public boolean get_IsCurrentCellDirty ()

public function get IsCurrentCellDirty () : boolean

No aplicable.

Valor de propiedad

true si la celda actual tiene cambios sin confirmar; en caso contrario, false.

Si el control DataGridView no está enlazado a datos, se confirma la edición de una celda cuando el usuario pase a otra celda.

Si los encabezados de fila son visibles, se mostrará un glifo del lápiz en el encabezado de la fila que contiene una celda con cambios no confirmados.

Si IsCurrentCellDirty es true y la celda actual aloja un control de edición, puede recuperarlo mediante la propiedad EditingControl.

En el ejemplo de código siguiente se utiliza la propiedad IsCurrentCellDirty para determinar si se confirmará un valor de celda y se provocará el evento CellValueChanged desde un controlador del evento CurrentCellDirtyStateChanged. Este ejemplo de código forma parte de un ejemplo más extenso que se proporciona en Cómo: Deshabilitar botones en una columna de botones del control DataGridView de formularios Windows Forms.

// This event handler manually raises the CellValueChanged event
// by calling the CommitEdit method.
void dataGridView1_CurrentCellDirtyStateChanged(object sender,
    EventArgs e)
{
    if (dataGridView1.IsCurrentCellDirty)
    {
        dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
    }
}

// If a check box cell is clicked, this event handler disables  
// or enables the button in the same row as the clicked cell.
public void dataGridView1_CellValueChanged(object sender,
    DataGridViewCellEventArgs e)
{
    if (dataGridView1.Columns[e.ColumnIndex].Name == "CheckBoxes")
    {
        DataGridViewDisableButtonCell buttonCell =
            (DataGridViewDisableButtonCell)dataGridView1.
            Rows[e.RowIndex].Cells["Buttons"];

        DataGridViewCheckBoxCell checkCell =
            (DataGridViewCheckBoxCell)dataGridView1.
            Rows[e.RowIndex].Cells["CheckBoxes"];
        buttonCell.Enabled = !(Boolean)checkCell.Value;

        dataGridView1.Invalidate();
    }
}

Windows 98, Windows 2000 Service Pack 4, Windows Millennium, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0
¿Te ha resultado útil?
(Caracteres restantes: 1500)
© 2013 Microsoft. Reservados todos los derechos.