Hi everbody,
I'm trying to format a bound DateTimeColumn to show only the short dateformat without the time. I have tried everything, but it does not work.
I tried:
Format = Short and Custom
FormatString = {0:d}
FormatString = d
I read the online documentation but it does not work. Does anyone have a solution for this?
Thank you very much and have a nice christmas!
Markus
I'm trying to format a bound DateTimeColumn to show only the short dateformat without the time. I have tried everything, but it does not work.
I tried:
Format = Short and Custom
FormatString = {0:d}
FormatString = d
I read the online documentation but it does not work. Does anyone have a solution for this?
Thank you very much and have a nice christmas!
Markus
9 Answers, 1 is accepted
0
Hello Markus,
Thank you for contacting us.
The Format property of the GridViewDateTimeColumn is used to format the value of the editor which is initialized when you want to edit a cell's value (more information about editors - Editors). If you want to change the format string of the displayed value, when not in edit mode you need to change the FormatString property. For example in order to set the format string to Short format you can use the following code:
I have also attached a sample project which demonstrates this functionality.
I hope this helps.
Regards,
George
Telerik
Thank you for contacting us.
The Format property of the GridViewDateTimeColumn is used to format the value of the editor which is initialized when you want to edit a cell's value (more information about editors - Editors). If you want to change the format string of the displayed value, when not in edit mode you need to change the FormatString property. For example in order to set the format string to Short format you can use the following code:
col.FormatString =
"{0:MM/dd//yyyy}"
;
I have also attached a sample project which demonstrates this functionality.
I hope this helps.
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Markus
Top achievements
Rank 1
answered on 26 Dec 2013, 03:32 PM
Hi George,
thank you for your answer. In the example it works fine. But my grid is bound to a BindingList and in Bound-Mode, the RadGridView is ignoring all the set format-attributes.
The GridViewDateTimeColumn straightly ignores the format properties.
Markus
thank you for your answer. In the example it works fine. But my grid is bound to a BindingList and in Bound-Mode, the RadGridView is ignoring all the set format-attributes.
The GridViewDateTimeColumn straightly ignores the format properties.
Markus
0
Accepted
Hi Markus,
Thank you for writing back.
I have modified the project I provided you with in the previous reply in a way that the grid is bound to a collection of objects which have a property of type DateTime, however it still seems that the FormatString property is working fine.
Please, find the attached project below. Let me know if the problem still exists in your application and if it does let me know how to reproduce it in my application or provide me one of your own.
Looking forward to your response.
Regards,
George
Telerik
Thank you for writing back.
I have modified the project I provided you with in the previous reply in a way that the grid is bound to a collection of objects which have a property of type DateTime, however it still seems that the FormatString property is working fine.
Please, find the attached project below. Let me know if the problem still exists in your application and if it does let me know how to reproduce it in my application or provide me one of your own.
Looking forward to your response.
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Markus
Top achievements
Rank 1
answered on 27 Dec 2013, 11:49 PM
Hi George,
I found out the problem in my application. The source was the loaded gridlayout.
Thank you very much for your quick help.
Best regards
Markus
I found out the problem in my application. The source was the loaded gridlayout.
Thank you very much for your quick help.
Best regards
Markus
0
Hello Markus,
Thank you for writing back.
I am glad that the issue you were facing is now resolved. However, have in mind that GridViewDateTimeColumn.FormatString property determines how to display the cell text when not in edit mode.
Do not hesitate to contact us if you have any additional questions.
Regards,
Desislava
Telerik
Thank you for writing back.
I am glad that the issue you were facing is now resolved. However, have in mind that GridViewDateTimeColumn.FormatString property determines how to display the cell text when not in edit mode.
Do not hesitate to contact us if you have any additional questions.
Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Tanser
Top achievements
Rank 1
answered on 22 Jan 2014, 02:32 PM
I have same problem on my project. How did you solve this problem?
0
Hello Tanser,
Thank you for contacting Telerik Support.
The GridViewDateTimeColumn.FormatString property sets the format of the date, when the cell is not currently being edited. The CustomFormat property is used to format the date once the user clicks on the cell to invoke the editor.
Our GridViewDateTimeColumn help article is quite useful about this topic. Here is just a sample code snippet:
If you experience any difficulties related to the date formatting, please provide your sample code. Thus, we would be able to investigate the precise case and suggest an appropriate solution.
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
Thank you for contacting Telerik Support.
The GridViewDateTimeColumn.FormatString property sets the format of the date, when the cell is not currently being edited. The CustomFormat property is used to format the date once the user clicks on the cell to invoke the editor.
Our GridViewDateTimeColumn help article is quite useful about this topic. Here is just a sample code snippet:
GridViewDateTimeColumn dateTimeColumn =
new
GridViewDateTimeColumn(
"DateTimeColumn"
);
//datetime format when not in edit mode
dateTimeColumn.FormatString =
"{0:MM/dd//yyyy}"
;
//datetimeformat when in edit mode
dateTimeColumn.Format = DateTimePickerFormat.Custom;
dateTimeColumn.CustomFormat =
"MM/dd"
;
this
.radGridView1.Columns.Add(dateTimeColumn);
If you experience any difficulties related to the date formatting, please provide your sample code. Thus, we would be able to investigate the precise case and suggest an appropriate solution.
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Scott
Top achievements
Rank 1
answered on 10 Feb 2017, 09:29 PM
What would the code be if I only wanted to show hours and minutes only? No seconds.
Thanks.
-Scott
0
Hi Scott,
Here is an example:
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Telerik by Progress
Here is an example:
GridViewDateTimeColumn dateTimeColumn = radGridView1.Columns[
"Date"
]
as
GridViewDateTimeColumn;
//datetime format when not in edit mode
dateTimeColumn.FormatString =
"{0:HH/mm}"
;
//datetimeformat when in edit mode
dateTimeColumn.Format = DateTimePickerFormat.Custom;
dateTimeColumn.CustomFormat =
"HH/mm"
;
Should you have any other questions do not hesitate to ask.
Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.