Answer Is!
there is some 'Grid control magic' going on here for an mm/dd/yyyy date only display of a datetime field. if a Date Column width is set to 68 or more, and a null date is encountered, then the width is greatly increased. estimated size is about 115. if the column width is set to 67 or less, then the date column width stays as specified!
Const GridDateWidth = 67 ' RJS 2/4/2010. was '68 ''' RJS 6/16/2009
BUG!
1. SQL 2005 Native Connection to fetch the data into an ADO recordset. 2. typical SQL: SELECT A1.DATEOPENED FROM OPPORTUNITY A1.... 2. Fill/refresh the datagrid through the recordset (not using SQL.TEXt, not using SLX OLE DB Provider). 3. Typical Grid building statements for Dates:
Set col = .Columns.Add(3) '3=DateTime col.FieldName = "ESTIMATEDCLOSE" col.Caption = "Est. Close" col.WIDTH = GridDateWidth col.Alignment = dgAlignRight col.FormatTYPE = 3 col.FormatString = "mm/dd/yyyy" col.Visible = True col.ReadOnly = True
Set col = .Columns.Add(3) '3=DateTime col.FieldName = "ACTUALCLOSE" col.Caption = "Actual Close" col.WIDTH = GridDateWidth col.Alignment = dgAlignRight col.FormatTYPE = 3 col.FormatString = "mm/dd/yyyy" col.Visible = True col.ReadOnly = True
So far so good....everything works/looks great.
Unfortunately, if there is a NULL date in a column, then that Column's Width at run time is about 115 pixels (instead of 68).....
We still need to sort
(tried using SQL:
CONVERT(VARCHAR(10),A1.PERIOD_END,,101) as PERIOD_END
but varchar dates don't sort correctly.....doh).
It looks like Delphi is converting the null dates to 'blank' date times and expanding the grid to almost double the size....
any ideas for a workaround?
Thanks! |