DateTime cell type is not displaying properly

Posted by: j2associates on 8 September 2017, 12:56 pm EST

  • Posted 8 September 2017, 12:56 pm EST

    Hello all,


    I set up a DateTimeCellType as below, but the data is still displayed as 3/9/2007. Am I missing something obvious here? Thanks in advance for any ideas and/or suggestions!


        Dim dTCT As New CellType.DateTimeCellType
        With dTCT
            .DateTimeFormat = CellType.DateTimeFormat.UserDefined
            .AMString = "am"
            .PMString = "pm"
            .UserDefinedFormat = "MM/dd/yyyy hh:mm:ss tt"
        End With
        Me
    .FpSpread1.ActiveSheet.Columns(2).CellType = dTCT

     
  • Replied 8 September 2017, 12:56 pm EST

    Hello,


    Is this Spread control bound to a DataSource? If it is, make sure you set DataAutoCellTypes property to False.

  • Replied 8 September 2017, 12:56 pm EST

    Thanks again Scott! That did the trick.


    If I understand the docs correctly, my code above would work properly if I had placed it in the DataColumnConfig event while leaving DataAutoCellTypes with its True value. That distinction is kind of subtle and not really intuitive. It would be nice if the spread control would handle that situation for me, eg allow my code above to work regardless of whether or not it was bound to a data source.


     

  • Replied 8 September 2017, 12:56 pm EST

    Hello,


    If you set your CellType after binding the Spread, then it woudl keep no matter the setting of DataAutoCellTypes. When you set the DataSource, if you leave this property to True, Spread will automatically set the CellTypes based on the type of DataColumn.


     

  • Replied 8 September 2017, 12:56 pm EST

    Thanks for the additional explanation. However, it appears that calling the clear method on a DataTable object resets everything. When I commented out this line of code,


    m_DataSet.Tables("Detail").Clear() 


    it worked as expected based upon your last response. It doesn't seem like the Clear method should cause the DataColumnConfigure event to be called again since it is clearing the data.

  • Replied 8 September 2017, 12:56 pm EST

    Hello,


    Calling the Clear method causes the DataSources to rebind themseleves to clear out all the data in the bound controls.This causes the event to fire again.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels