Link to home
Start Free TrialLog in
Avatar of Ghanisen
Ghanisen

asked on

Decimals and thousands separators in a numeric DataGrid Column

Hi,

I’d like column1 of my datagrid to be formatted to display numbers with a fixed number of decimals (e.g. 1, 2 or 3) and yet be formatted with  thousands  separators.

Does anyone know how to do that?

To format with thousands separators this is the code I use but it doesn’t allow for decimals:

Dim dgTextBoxColumn1 As DataGridTextBoxColumn = MyDataGrid.TableStyles("tProduits").GridColumnStyles("MyColumn")
dgTextBoxColumn1.Format = "#,#"

Any help shall be greatly appreciated.
ASKER CERTIFIED SOLUTION
Avatar of iboutchkine
iboutchkine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ghanisen
Ghanisen

ASKER

Hi Iboutchkine,

My question wasn't about currency data but only plain numeric data. So it should be "n" instead of "c".

I found also another way to do it with a custom format:

 Dim dgTextBoxColumn6 As DataGridTextBoxColumn = _
               dgr.TableStyles("tProduits"). _
               GridColumnStyles("QuantStock")
        ' Format avec séparateur de milliers prédéfini
        dgTextBoxColumn6.Format = "#.#0,000"

The number of 0 after the coma determines the number of decimals. It works.

Thank you for your effort. You still deserve 500 points. Bye Iboutchkine.