GridViewDateTimeColumn: Need Date without Time

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

    Posted 09 Nov 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
    Admin
    Dess avatar
    1601 posts

    Posted 09 Nov 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. UI for WinForms is Visual Studio 2017 Ready
  4. Gone2TheDogs
    Gone2TheDogs avatar
    22 posts
    Member since:
    May 2016

    Posted 09 Nov in reply to Dess Link to this post

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

Back to Top