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
1825
Format cell display text for different formats?
posted

I have a column that has values that can be different formats;

1 / 1.0 / $1.00 / 7.65%

The grid is for displaying the data, no editing.

How can i format the text values to what I want? I dont seem to be able to figure out the correct formating string.

Heres what I have atm, works on the whole column :), not the cell itself.

uwGrid_RptResult_Prt1_InitializeRow 

 If (e.Row.Cells("Category").Text.IndexOf("Percentage") > -1) Then  

    e.Row.Appearance.BackColor = System.Drawing.Color.FromName("Lime")  ' just so I can see I am in area I should be.

    e.Row.Cells("Category: Result").Column.Format = "#0.##%"  ' ok this does somethign but not sure what! the cell should be displaying 7.65% but i get 700%!

End If  

Any help would be most appreciated on this.

Thanks

Deasun

 

Parents
No Data
Reply
  • 1825
    posted

    This is what I came up with:

    for the % cells:

    e.Row.Cells("Category: Result").Value = String.Format(System.String.Format("{0:F2}", e.Row.Cells("Category: Result").Value))

    For the decimal cells:

    Dim intValueIs As Integer = Convert.ToDecimal(e.Row.Cells("Category: Result").Value)

    e.Row.Cells("Category: Result").Value = intValueIs

     

Children