This is a migrated thread and some comments may be shown as answers.

GridView GridViewDateTimeColumn

1 Answer 86 Views
GridView
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 15 Feb 2012, 02:25 PM
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.

 

 

 

 

 

 

 

 

           

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Boryana
Telerik team
answered on 20 Feb 2012, 09:26 AM
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 >>
Tags
GridView
Asked by
George
Top achievements
Rank 1
Answers by
Boryana
Telerik team
Share this question
or