Evento cellFormatting en DataGridView
Publicado por José (41 intervenciones) el 20/10/2016 17:31:56
Hola,
tengo la version VB2010;
tengo un problema con el evento cellFormatting del DataGridView.
Se como comparar el valor ded una celda del DataGridView con un valor del campo del formulario o un valor fijo. Esto funciona, pero mi problema es el siguiente: tengo un formulario con varios campos y datagridView; en este ActivegDataGrodView tengo una columna EC! y Otra columna EM! yo deseo que cuando la celda EC! tenga el mismo valor Que la celda EM! de la misma fila (de la misma fila), la celda EC! se coloree en rojo; eso es todo.
A ver si me pueden ayudar,;gracias.
José
Private Sub ACTIVEGDataGridView_CellFormatting(sender As System.Object, e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles ACTIVEGDataGridView.CellFormatting
Dim P, Pp As String, Te, Ie, Im As Integer, Tr As Double, Trd As Double
Te = CType(Me.TOPECARTS.Text, Integer) : Tr = CType(Me.TOPREUSITES.Text, Double) : Trd = CType(Me.TOPRENDEMENTS.Text, Double)
P = "R1" : Call FORMATERCEL_RENDEMENTS(e, P, Tr)
P = "R2" : Call FORMATERCEL_RENDEMENTS(e, P, Tr)
P = "R3" : Call FORMATERCEL_RENDEMENTS(e, P, Tr)
'.................................
end sub
Private Sub FORMATERCEL_RENDEMENTS(e As System.Windows.Forms.DataGridViewCellFormattingEventArgs, P As String, R As Double)
If ACTIVEGDataGridView.Columns(e.ColumnIndex).Name = P Then
If e.Value IsNot Nothing And Not IsDBNull(e.Value) Then
Dim Ivalor As Double = CType(e.Value, Double)
If Ivalor > R Then
e.CellStyle.BackColor = Color.LightSkyBlue
End If
End If
End If
End Sub
tengo la version VB2010;
tengo un problema con el evento cellFormatting del DataGridView.
Se como comparar el valor ded una celda del DataGridView con un valor del campo del formulario o un valor fijo. Esto funciona, pero mi problema es el siguiente: tengo un formulario con varios campos y datagridView; en este ActivegDataGrodView tengo una columna EC! y Otra columna EM! yo deseo que cuando la celda EC! tenga el mismo valor Que la celda EM! de la misma fila (de la misma fila), la celda EC! se coloree en rojo; eso es todo.
A ver si me pueden ayudar,;gracias.
José
Private Sub ACTIVEGDataGridView_CellFormatting(sender As System.Object, e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles ACTIVEGDataGridView.CellFormatting
Dim P, Pp As String, Te, Ie, Im As Integer, Tr As Double, Trd As Double
Te = CType(Me.TOPECARTS.Text, Integer) : Tr = CType(Me.TOPREUSITES.Text, Double) : Trd = CType(Me.TOPRENDEMENTS.Text, Double)
P = "R1" : Call FORMATERCEL_RENDEMENTS(e, P, Tr)
P = "R2" : Call FORMATERCEL_RENDEMENTS(e, P, Tr)
P = "R3" : Call FORMATERCEL_RENDEMENTS(e, P, Tr)
'.................................
end sub
Private Sub FORMATERCEL_RENDEMENTS(e As System.Windows.Forms.DataGridViewCellFormattingEventArgs, P As String, R As Double)
If ACTIVEGDataGridView.Columns(e.ColumnIndex).Name = P Then
If e.Value IsNot Nothing And Not IsDBNull(e.Value) Then
Dim Ivalor As Double = CType(e.Value, Double)
If Ivalor > R Then
e.CellStyle.BackColor = Color.LightSkyBlue
End If
End If
End If
End Sub
Valora esta pregunta


0