GridView GridViewDateTimeColumn

2 posts, 0 answers
  1. George
    George avatar
    6 posts
    Member since:
    Jul 2011

    Posted 15 Feb 2012 Link to this post

    I have a RadGridView with a GridViewDateTimeColumn added as follows

    With radGridView

        Dim dtFromCol As New GridViewDateTimeColumn("FromDate")

     

        With dtFromCol

            .Format = DateTimePickerFormat.Custom

            .CustomFormat = "M/d/yy"    'I'm looking for the shortest date format, i.e. 1/1/12 or 12/31/12

            .Width = 70

        End With
        .Columns.Add(dtFromCol)
    .
    .Other columns follow
    .
    End With

    When I click the cell I get the datetime picker & the date selected shows up in the desired format (M/d/yy) in the cell, but when I click or Tab away from the cell the cell value changes to a long date format like 2/14/2012 12:00:00 AM . I'm trying not to display the full year (2012) and I don't want the time.
    I have tryed customizing the cell's editor in the CellEditorInitialized event or forcing the desired date into the cell in the CellValidated event to no avail. Thanks for any help.

     

     

     

     

     

     

     

     

               

     

     

     

     

     

  2. Boryana
    Admin
    Boryana avatar
    330 posts

    Posted 20 Feb 2012 Link to this post

    Hi George,

    Thank you for writing.

    The CustomFormat property sets the date format in the editor appearing in a GridViewDateTimeColumn cell. To format the date in all cells (which are not in edit mode) you should use the FormatString property. For further information and code snippets please refer to the following article: GridViewDateTimeColumn.

    I hope you find my answer useful. Let me know if you have further questions. 

    All the best,
    Boryana
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top