Can't seem to set FormatString for currency

4 posts, 0 answers
  1. hkdave95
    hkdave95 avatar
    245 posts
    Member since:
    Nov 2006

    Posted 27 Jul 2008 Link to this post

    Hi

    I am trying to set the FormatString for a column in GridView.

    I have tried "{0:C}" and "{C}", but it does not seem to retain the value.

    I have even tried entering the format string into the designer but with no success.

    Is this a know problem ? Or am I doing something wrong ?

    Kind Regards
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 28 Jul 2008 Link to this post

    Hi hkdave95,

    Thank you for the interest in RadGridView.

    You will need to set the FormatString after binding the grid to data:

    ((GridViewDataColumn)
    this.radGridView1.Columns["Price"]).FormatString = "{0:C}";

    Hope this helps. Don't hesitate to contact us if you have other questions.

    Kind regards,
    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. hkdave95
    hkdave95 avatar
    245 posts
    Member since:
    Nov 2006

    Posted 28 Jul 2008 Link to this post

    Hi

    Thanks for the reply.

    This works great for the first column that I set it for but it does not work if I have two or three columns that need formatting.

    Could you please confirm that I am doing it correctly ...

    Me.rgvTransactions.Columns("T_nPrice").FormatString = "{0:C}" 
    Me.rgvTransactions.Columns("T_nVATRate").FormatString = "{0:P}" 
    Me.rgvTransactions.Columns("T_nTotal").FormatString = "{0:C}" 

    T_nPrice - works ok
    T_nVATRate - no formatting
    T_nTotal - no formatting

    Kind Regards

    David
  5. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 29 Jul 2008 Link to this post

    Hello hkdave95,

    Thank you for getting back to me.

    I could not manage to repro the issue.
    Could you take look in Designer.vb and tell me what is the type of T_nPrice,T_nVATRate and T_nTotal columns?

    The Type should be  GridViewDecimalColumn, and in the initialization section T_nVATRate and T_nTotal should have properties .DataType = GetType(Decimal)

    I hope this helps, if you have other questions, do not hesitate to contact me again.

    Sincerely yours,
    Peter
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top