We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Setting the date format in a data bound grid

Thread ID:





18320 Aug 27,2004 02:41 PM UTC Aug 27,2004 03:38 PM UTC WinForms 2
Tags: GridControl
Asked On August 27, 2004 02:41 PM UTC

Hi, I have a databound grid and the data source has a DateTime column. By default the grid only displays the date and not the time (and the date selection control). I tried to set the format of the column in the model; however, that had no effect. What do I need to do? m_gridData.DataSource = m_dsData.Tables[0].DefaultView; m_gridData.Model.ColStyles["DateStamp"].CellValueType = typeof(DateTime); m_gridData.Model.ColStyles["DateStamp"].Format = "HH:mm MM/dd/yy"; Is the code snipit... originally I didn''t have the CellValueType call in there but thought maybe that explicitly setting the type might help; however, it didn''t. Thank you in advance, Jon

Administrator [Syncfusion]
Replied On August 27, 2004 03:05 PM UTC

To set style properties on a column in a GridDataBoundGrid, you use the GridBoundColumn.StyleInfo object instead of the ColStyle object used for GridControl. So, try GridStyleInfo style = m_gridData.Binder.InternalColumns["DataStamp"].StyleInfo; style.CellValueType = typeof(DateTime); style.Format = "HH:mm MM/dd/yy"; if you have not explicitly added GridBoundColumns to your grid. If you have added GridBoundCOlumns, use: GridStyleInfo style = m_gridData.GridBoundColumns["DataStamp"].StyleInfo; style.CellValueType = typeof(DateTime); style.Format = "HH:mm MM/dd/yy";

Replied On August 27, 2004 03:38 PM UTC

Thank you for the quick response! Jon


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon