GridViewDateTimeColumn: Need Date without Time

3 posts, 1 answers
  1. Gone2TheDogs
    Gone2TheDogs avatar
    66 posts
    Member since:
    May 2016

    Posted 09 Nov 2016 Link to this post

    I have a GridViewDateTimeColumn that I am trying to format to show only the date in the format:  "MM/dd/yyyy", but instead I get the time in the form of all zeros following the date. (see screen shot).

    Property Settings:

    Format:  Custom

    FormatInfo: en-IN

    CustomFormat:  MM/dd/yyyy

    EditorType:  DateTimePicker

    FilteringMode: Date

    Is it possible to get rid of the time and just display the date? If so, how?

     

     

     

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4077 posts

    Posted 09 Nov 2016 Link to this post

    Hello Bob,

    Thank you for writing.  

    You can find below a sample code snippet demonstrating how to setup the GridViewDateTimeColumn and specify the format for the cells and the editor itself:
    public RadForm1()
    {
        InitializeComponent();
        GridViewDateTimeColumn dateTimeColumn = new GridViewDateTimeColumn("Date");
        this.radGridView1.Columns.Add(dateTimeColumn);
     
        dateTimeColumn.FormatString = "{0:MM/dd/yyyy}"; // specify cell's format
     
        dateTimeColumn.Format = DateTimePickerFormat.Custom;//specify the editor's format
        dateTimeColumn.CustomFormat = "MM/dd/yyyy";
         
        this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        for (int i = 0; i < 10; i++)
        {
            this.radGridView1.Rows.Add(DateTime.Now.AddDays(i));
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    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.
  3. Gone2TheDogs
    Gone2TheDogs avatar
    66 posts
    Member since:
    May 2016

    Posted 09 Nov 2016 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Thanks Dess. Thank you for the quick reply!  I looked everywhere!

Back to Top