DataGridView.CellStyleContentChanged Evento

Definición

Se produce cuando cambia uno de los valores de un estilo de celda.

public:
 event System::Windows::Forms::DataGridViewCellStyleContentChangedEventHandler ^ CellStyleContentChanged;
public event System.Windows.Forms.DataGridViewCellStyleContentChangedEventHandler CellStyleContentChanged;
member this.CellStyleContentChanged : System.Windows.Forms.DataGridViewCellStyleContentChangedEventHandler 
Public Custom Event CellStyleContentChanged As DataGridViewCellStyleContentChangedEventHandler 

Tipo de evento

Ejemplos

En el ejemplo de código siguiente se muestra el uso de este miembro. En el ejemplo, un controlador de eventos informa sobre la aparición del CellStyleContentChanged evento. Este informe le ayuda a aprender cuándo se produce el evento y puede ayudarle a depurar. Para informar sobre varios eventos o eventos que se producen con frecuencia, considere la posibilidad de reemplazar MessageBox.Show por Console.WriteLine o anexar el mensaje a una línea TextBoxmúltiple.

Para ejecutar el código de ejemplo, péguelo en un proyecto que contenga una instancia de tipo DataGridView denominada DataGridView1. A continuación, asegúrese de que el controlador de eventos está asociado al CellStyleContentChanged evento.

private void DataGridView1_CellStyleContentChanged(Object sender, DataGridViewCellStyleContentChangedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "CellStyle", e.CellStyle );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "CellStyleScope", e.CellStyleScope );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "CellStyleContentChanged Event" );
}
Private Sub DataGridView1_CellStyleContentChanged(sender as Object, e as DataGridViewCellStyleContentChangedEventArgs) _ 
     Handles DataGridView1.CellStyleContentChanged

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "CellStyle", e.CellStyle)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "CellStyleScope", e.CellStyleScope)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"CellStyleContentChanged Event")

End Sub

Comentarios

El CellStyleContentChanged evento tiene lugar cuando cambia un valor de propiedad de un DataGridViewCellStyle objeto devuelto por una de las siguientes propiedades:

Sin embargo, si una de estas propiedades se establece en otro DataGridViewCellStyle, se produce el evento PropertyNameChanged correspondiente, pero el CellStyleContentChanged evento no se produce.

Para las propiedades row, column y cell, el nombre del evento PropertyNameChanged comienza por "", "RowColumn" o "Cell" (por ejemplo, RowDefaultCellStyleChanged).

Para obtener más información sobre cómo controlar eventos, consulte Control y generación de eventos.

Se aplica a

Consulte también