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.
Unfortunately, activation email could not send to your email. Please try again.

Setting the date format in a data bound grid

Thread ID:

Created:

Updated:

Platform:

Replies:

18320 Aug 27,2004 10:41 AM Aug 27,2004 11:38 AM Windows Forms 2
loading
Tags: GridControl
Jon
Asked On August 27, 2004 10:41 AM

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 11:05 AM

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";

Jon
Replied On August 27, 2004 11:38 AM

Thank you for the quick response! Jon

CONFIRMATION

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.

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.

;