Set the format string through the designer

2 posts, 0 answers
  1. Pavel
    Pavel avatar
    13 posts
    Member since:
    Oct 2009

    Posted 29 Sep 2016 Link to this post

    I need to format this "123456789" to this "12-3456789" in a column.
    I know I can do this in the code, but is there a way to do this through the designer?
    I tried setting the FormatString of the GridViewTextBoxColumn to {0:##-#######} but that doesn't seem to do anything.


  2. Dimitar
    Dimitar avatar
    2949 posts

    Posted 30 Sep 2016 Link to this post

    Hello P G,

    Please note that columns that contain text cannot be automatically formatted. To achieve this you need to manually format the value (parse it to numeric or another format) which can be done in the CellFormating event:
    private void RadGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
        if (e.Column.Name == "column1" && e.CellElement.Value != null)
            int value = int.Parse(e.CellElement.Value.ToString());
            e.CellElement.Text = string.Format("{0:##-#######}", value);

    Do not hesitate to contact us if you have other questions.
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top