Radgridview Column formating at design time

7 posts, 1 answers
  1. Hasan
    Hasan avatar
    2 posts
    Member since:
    Aug 2010

    Posted 30 Jan 2011 Link to this post

    How you can define a date time column FormatString property at design time to show only date in the column and not the time. If it is not possible at design time what is the way to do it in vb.
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 30 Jan 2011 Link to this post

    Hi Hasan,

    In code:
    dateColumn.FormatString = "{0:d}"

    See MSDN for Format String Info

    In the Designer

        • Go to the properties of the RadGridView
        • Open the Columns collection editor
        • Find or add your date time column
        • Set the Format String to "{0:d}"

    Hope that helps
    Richard

    EDIT: Note that you can also set the same information through the Smart Tag >> Open Property Builder

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Hasan
    Hasan avatar
    2 posts
    Member since:
    Aug 2010

    Posted 06 Feb 2011 Link to this post

    Thanks for the help. It is showing the correct date format but when I export the data in pdf it is still showing the date time format. How to fix that.
  5. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 06 Feb 2011 Link to this post

    Hello,

    Please have a look at the following forum post which explains formatting PDF date columns.
    Hope that helps
    Richard
  6. Jennifer
    Jennifer avatar
    1 posts
    Member since:
    Mar 2012

    Posted 11 May 2012 Link to this post

    I have an unbound data grid that I fill with data.  I also allow users to modify the data.
    The columns I am interested in contain US currency and percentage.  I have opened up the property builder and added the format {0:c} (and various others) to the FormatString property to get the deesired effects.  I also tried setting the property in code as well; that didn't work either.

    I cannot get the currency (or percentage) to display in the columns.
    Can someone help me determine what I am doing wrong?

    Thanks!
    Bob
  7. Bob
    Bob avatar
    41 posts
    Member since:
    Mar 2012

    Posted 11 May 2012 Link to this post

    Wrong email / Account - Sorry.

    I have an unbound data grid that I fill with data. I also allow users to modify the data.
    The columns I am interested in contain US currency and percentage. I have opened up the property builder and added the format {0:c} (and various others) to the FormatString property to get the deesired effects. I also tried setting the property in code as well; that didn't work either.

    I cannot get the currency (or percentage) to display in the columns.
    Can someone help me determine what I am doing wrong?

    Thanks!
    Bob
  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 16 May 2012 Link to this post

    Hello,

    Thank you for writing.

    Here is a small example which demonstrates how to set the FormatString of a decimal column to both currency and percentage:
    public Form1()
    {
        InitializeComponent();
     
        GridViewDecimalColumn col1 = new GridViewDecimalColumn("Currency");
        col1.FormatString = "{0:c}";
        radGridView1.Columns.Add(col1);
         
        GridViewDecimalColumn col2 = new GridViewDecimalColumn("Percentage");
        col2.FormatString = "{0:p}";
        radGridView1.Columns.Add(col2);
     
        for (int i = 0; i < 10; i++)
        {
            radGridView1.Rows.Add(i * 3.14, (double)i/10);
        }
    }

    I hope this helps.
     
    All the best,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready