ComponentOne FlexGrid for WinForms facilitates users to enter currency values in the columns of the grid. This feature is exposed with the Format property of the Column object in C1FlexGrid. With this property, it is possible to change the format of any integer type column to represent currencies. It is seen that the currency format is subject to the current locale setting. Thus, for the scenarios where currencies for the same locale must be displayed, this property is used.
' Currency.
_flex.Cols(2).Format = "c"
However, there are many use cases where different currencies are to be used in a single grid. Using OwnerDrawCell, all you need is to pass the Format string for the cell/column/row, and you escape this “limitation” . Please refer to the following snippet which accomplishes this:
Private Sub _flex_OwnerDrawCell(sender As System.Object, e As OwnerDrawCellEventArgs) Handles _flex.OwnerDrawCell
Select Case _flex.Cols(e.Col).Name
Case "Pound"
Try
Dim i As Integer = CInt(Me._flex(e.Row, e.Col))
e.Text = String.Format("{0:£#,##0}", i)
Catch
End Try
Exit Select
Case "Dollar"
Try
Dim i As Integer = CInt(Me._flex(e.Row, e.Col))
e.Text = String.Format("{0:$#,##0}", i)
Catch
End Try
Exit Select
Case "Euro"
Try
Dim i As Integer = CInt(Me._flex(e.Row, e.Col))
e.Text = String.Format("{0:€#,##0}", i)
Catch
End Try
Exit Select
Case "Yen/Yuan"
Try
Dim i As Integer = CInt(Me._flex(e.Row, e.Col))
e.Text = String.Format("{0:¥#,##0}", i)
Catch
End Try
Exit Select
Case "Won"
Try
Dim i As Integer = CInt(Me._flex(e.Row, e.Col))
e.Text = String.Format("{0:?#,##0}", i)
Catch
End Try
Exit Select
Case Else
Exit Select
End Select
End Sub
Find the sample here: http://our.componentone.com/wp-content/uploads/2014/09/FlexGridCurrencyVB.zip