Limit decimal places display in DataGridColumnStyle

Taking a decimal from an SQL query, the DataGrid displays results with 6 decimal places. I just need 2, is it possible to truncate the rest  Unfortunately I'm not understanding from the SDK doc how I can really do this.

Answer this question

Limit decimal places display in DataGridColumnStyle

  • Benjaminhf

    Take a look in 
    http://www.syncfusion.com/FAQ/WinForms/default.asp#44

    You would want to format the column

    BTW you could do it in SQL too by using some of the functions and just truncate it before it even gets to the UI, of course if you are doing math then you might not want to do that.

  • dosler

    I did ROUND() it in SQL server to 2 decimal places, the DataGrid displays it via a strong-typed DataSet with decimal for that column, and it shows 7.120000, 20.450000.

    Yes I want to format the GridColumnStyle and that's where I'm stumped - somehow I can't absorb what the formatting docs are talking about..... saying "c" for plain currency (and so on), and tied closely to the CultureInfo. I just want to format it to 2 decimal places, and don't want a culture involved in this, so I'm confused how to avoid that.

  • coreywelsh

    Oh wait, sorry..... I think I see a hint in the code examples.... set Format = "f2". I will try that when I enter office.
  • Cordt

    Yes! f2 is the correct formatting string to use. Thanks!
  • Ikram Shaikh

    Well when doing it the SQL way you would cast or convert (using cast() or Convert() functions) the rounded result to a money type. That way when the dataset is built and all it will use a different datatabype then decimal. 

    Though you are getting there with the set format "c", that will do it too.

  • Limit decimal places display in DataGridColumnStyle