ComponentOne FlexGrid for WinForms
Formatting a Cell with Decimal Content
FlexGrid for WinForms Task-Based Help > Formatting Cells > Formatting a Cell with Decimal Content

To format a cell that contains decimal numbers, set the Format property either in the designer or in code. In this example, numbers already entered in the first column will be formatted to a decimal amount.

In the Designer

  1. Select Column 1 in the grid. This will open the Column Tasks menu for Column 1.
  2. Click the ellipsis button in the Format String box to open the Format String dialog box.
  3. Under Format type select Custom and set the Custom format to $#,##0.00.
  4. Click OK to close the Format String dialog box.

Alternatively, the Format property can also be set using the C1FlexGrid Column Editor:

  1. Open the C1FlexGrid Column Editor. For details on how to access the C1FlexGrid Column Editor, see Accessing the C1FlexGrid Column Editor.
  2. Select Column 1 from the right pane and set the Format property to $#,##0.00 in the left pane.
  3. Click OK to close the editor.

In Code

Add the following code to the Form_Load event:

To write code in Visual Basic

Visual Basic
Copy Code
Me.C1FlexGrid1.Cols(1).Format = "$#,##0.00"

To write code in C#

C#
Copy Code
this.c1FlexGrid1.Cols[1].Format = "$#,##0.00";

Note: The format specifier follows the standard .NET conventions. Use ',' for thousand separators and '.' for the decimal, regardless of locale.

This topic illustrates the following:

In this example, the numbers in the first column are converted to a dollar amount.


See Also