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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Changing date format

Thread ID:

Created:

Updated:

Platform:

Replies:

17278 Aug 5,2004 12:23 AM UTC Aug 10,2004 05:22 AM UTC WinForms 3
loading
Tags: GridControl
Damien Sawyer
Asked On August 5, 2004 12:23 AM UTC

Hi, I have a grid bound to a datatable. The datatable is linked to a SQL table. One of the columns is smalldatetime. How do i get the grid to display hours and minutes after the date? The data is in the table. I''ve been trying the following to no evail There is no error message, however it does not achieve the desired result. Thanks in advance, Damien Me.grdStatusHistory.DataSource = dtResult Me.grdStatusHistory.Binder.SetDataBinding(dtResult, "") Me.grdStatusHistory.Model.ColStyles(Me.grdStatusHistory.Binder.NameToColIndex("dDateChanges")).Format = "dd-MMM-yyyy hh:mm" Me.grdStatusHistory.Refresh()

Administrator [Syncfusion]
Replied On August 5, 2004 05:22 AM UTC

The style.Format does not work unless you also set the style.CellValueType to reflect the proper System.Type. So try Me.grdStatusHistory.Model.ColStyles(Me.grdStatusHistory.Binder.NameToColIndex("dDateChanges")).CellValueType = GetType(DateTime)

Damien Sawyer
Replied On August 9, 2004 11:23 PM UTC

Thanks for that Clay, Unfortunately it didn''t work. My code now looks like .... Notice that I did the formatting twice, with both "Date Changed" and "dDateChanged"... just to check. Any ideas? Thanks, DS Dim sSQL As String = "" Dim dtResult As New DataTable sSQL += "SELECT " sSQL += "iID [ID]," sSQL += "OrderNumber [Order Number]," sSQL += "iItemID [Item ID]," sSQL += "SecondID [Second ID]," sSQL += "iStatusOld [Old Status]," sSQL += "iStatusNew [New Status]," sSQL += "dDateChanges [Date Changed] " sSQL += " from dbo.tblOrderStatusChangeLog " sSQL += "WHERE OrderNumber = " & Me._iOrderNumber.ToString & " " sSQL += "AND SecondID = ''" & Me._cLITM.Trim & "'' " sSQL += "order by dDateChanges" Dim daLogs As SqlDataAdapter = New SqlDataAdapter(sSQL, Me._oRoot.oSQLConn) daLogs.Fill(dtResult) Me.grdStatusHistory.DataSource = dtResult Me.grdStatusHistory.Binder.SetDataBinding(dtResult, "") Me.grdStatusHistory.Model.ColStyles(Me.grdStatusHistory.Binder.NameToColIndex("dDateChanges")).CellValueType = GetType(DateTime) Me.grdStatusHistory.Model.ColStyles(Me.grdStatusHistory.Binder.NameToColIndex("dDateChanges")).Format = "dd-MMM-yyyy hh:mm" Me.grdStatusHistory.Model.ColStyles(Me.grdStatusHistory.Binder.NameToColIndex("Date Changed")).CellValueType = GetType(DateTime) Me.grdStatusHistory.Model.ColStyles(Me.grdStatusHistory.Binder.NameToColIndex("Date Changed")).Format = "dd-MMM-yyyy hh:mm" Me.grdStatusHistory.Refresh()

Administrator [Syncfusion]
Replied On August 10, 2004 05:22 AM UTC

I am sorry, it did not register with me that you were using ColStyles. If grdStatusHistory is a GridDataBoundGrid, then you will need to set the style for the column using the GridBoundColumn object for the column. So, if you have not explicitly added GridBoundColumns, you would use code like grdStatusHistory.Binder.InternalColumns("dDateChanges").StyleInfo.CellValueType = GetType(DateTime) Me.grdStatusHistory.Binder.InternalColumns("dDateChanges").StyleInfo.Format = "dd-MMM-yyyy hh:mm" If you have explicitly added GridBoundColumns, then you use the grdStatusHistory.GridBoundColumns collection set the styles on the columns.

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.

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

;