在显示状态下对数据进行格式化,通过ColFormat的确无法满足你同时显示3中货币符号的要求,看通过以下方法是否满足你的需求:
[code]Private Sub Form_Load()
' 设置表格的自画方法
VSFlexGrid1.OwnerDraw = flexODContent
' 设置表格的行数
VSFlexGrid1.Rows = 21
VSFlexGrid1.Cols = 5
VSFlexGrid1.TextMatrix(1, 1) = 1234.5
VSFlexGrid1.TextMatrix(1, 2) = 1234.5
VSFlexGrid1.TextMatrix(1, 3) = 1234.5
End Sub
Private Sub VSFlexGrid1_DrawCell(ByVal hDC As Long, ByVal Row As Long, ByVal Col As Long, ByVal Left As Long, ByVal Top As Long, ByVal Right As Long, ByVal Bottom As Long, Done As Boolean)
If Row < VSFlexGrid1.FixedRows Then
Exit Sub
End If
' 设置货币符号
If Col = 1 Then
If Val(VSFlexGrid1.TextMatrix(Row, Col)) <> 0 Then
VSFlexGrid1.TextMatrix(Row, Col) = Format(Val(VSFlexGrid1.TextMatrix(Row, Col)), "$###,###.##")
End If
ElseIf Col = 2 Then
If Val(VSFlexGrid1.TextMatrix(Row, Col)) <> 0 Then
VSFlexGrid1.TextMatrix(Row, Col) = Format(Val(VSFlexGrid1.TextMatrix(Row, Col)), "¥###,###.##")
End If
ElseIf Col = 3 Then
If Val(VSFlexGrid1.TextMatrix(Row, Col)) <> 0 Then
VSFlexGrid1.TextMatrix(Row, Col) = Format(Val(VSFlexGrid1.TextMatrix(Row, Col)), " |