VSFlexGrid Control > VSFlexGrid Properties, Events, and Methods > VSFlexGrid Events > CellChanged Event |
Fired after a cell's contents change.
Private Sub VSFlexGrid_CellChanged( ByVal Row As Long, ByVal Col As Long)
This event allows you to perform some processing whenever the contents of a cell change, regardless of how they were changed (e.g. user typed data into the cell, data got loaded from a database, or data was assigned to the grid through code). This is useful to provide conditional formatting and dynamic data summaries (that get updated automatically whenever the data changes).
For example, the following code formats negative values in bold red:
Private Sub Form_Load()
Dim r&, c&
fg.Editable = flexEDKbdMouse
fg.ColFormat(-1) = "#,###.##"
For r = fg.FixedRows To fg.Rows - 1
For c = fg.FixedCols To fg.Cols - 1
fg.TextMatrix(r, c) = Rnd * 1000 - 500
Next
Next
End Sub
Private Sub fg_CellChanged(ByVal Row As Long, ByVal Col As Long)
If fg.TextMatrix(Row, Col) < 0 Then
fg.Cell(flexcpForeColor, Row, Col) = RGB(200, 100, 100)
fg.Cell(flexcpFontBold, Row, Col) = RGB(200, 100, 100)
Else
fg.Cell(flexcpCustomFormat, Row, Col) = False
End If
End Sub