Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4695
ultragrid column format -- Truncate
posted

Dear all,

I have below statement, how to make the number to be truncate to be 1 decimal places.

this.ultragrid1.displaylayout.bands[0].columns["CASH"].Format="#,##0.00"

1.22 --> 1.2

1.26 --> 1.2, not 1.3??

  • 3707
    posted

    rchiu5hk said:

    Dear all,

    I have below statement, how to make the number to be truncate to be 1 decimal places.

    this.ultragrid1.displaylayout.bands[0].columns["CASH"].Format="#,##0.00"

    1.22 --> 1.2

    1.26 --> 1.2, not 1.3??

    Give the code I typed out below a shot.

    this.ultraGrid1.DisplayLayout.Bands[0].Columns["CASH"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Currency;
    this.ultraGrid1.DisplayLayout.Bands[0].Columns["CASH"].MaskDisplayMode = MaskMode.IncludeLiterals;
    this.ultraGrid1.DisplayLayout.Bands[0].Columns["CASH"].FormatInfo = System.Globalization.CultureInfo.CurrentCulture;

     

  • 469350
    Offline posted

    The Format property basically just uses the ToString method of the cell's value. So you can check Microsoft's documentation to see if there is any format that will do what you want based on the DataType you are using here.

    As far as I know, there's no numeric formatting that will truncate a value, but I could be wrong.

    If I am right, then the alternative would be to hide the real column of data in your grid and add an Unbound column. Then you can handle the InitializeRow event of the grid can get the value in the real cell and modify it however you like and then set the value on the unbound column accordingly.