views:

1047

answers:

2

Hi, I am trying to change the format of a cell in a datagridview using the following code.

        this.dataGridView[2, 1].ValueType = typeof(decimal);
        this.dataGridView[2, 1].Value = 500;
        this.dataGridView[2, 1].Style.BackColor = System.Drawing.Color.OrangeRed;
        this.dataGridView[2, 1].Style.Format = "c";

The colour of the cell changes but it doesnt not show in currency format.

Anyone know why?

A: 

Are you ensuring that the value assigned to .Value is numeric? (i.e. not a string)

Mitch Wheat
i thought that at first too so thats why i set the value type to decimal as shown above...
Grant
A: 

In the examples I've seen, the "c" format is lowercased. You may not need the "2" either.

David Andres
thanks David - tried that but the same result.
Grant