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

    <P>Hello all,</P>
    <P>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!<FONT size=1></P>
    <P></FONT>    <SPAN class=kwd>Dim</SPAN> dTCT <SPAN class=kwd>As New</SPAN> CellType.DateTimeCellType<BR>    <SPAN class=kwd>With</SPAN> dTCT<BR>        .DateTimeFormat = CellType.DateTimeFormat.UserDefined<BR>        .AMString = <SPAN class=st>"am"</SPAN><BR>        .PMString = <SPAN class=st>"pm"</SPAN><BR>        .UserDefinedFormat = <SPAN class=st>"MM/dd/yyyy hh:mm:ss tt"</SPAN><BR>    <SPAN class=kwd>End With<BR>    Me</SPAN>.FpSpread1.ActiveSheet.Columns(2).CellType = dTCT</P> 
  • Replied 8 September 2017, 12:56 pm EST

    <P>Hello,</P>
    <P>Is this Spread control bound to a DataSource? If it is, make sure you set DataAutoCellTypes property to False.</P>
  • Replied 8 September 2017, 12:56 pm EST

    <P>Thanks again Scott! That did the trick. </P>
    <P>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. </P>
    <P> </P>
  • Replied 8 September 2017, 12:56 pm EST

    <P>Hello,</P>
    <P>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.</P>
    <P> </P>
  • Replied 8 September 2017, 12:56 pm EST

    <P>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, </P>
    <P><FONT size=2>m_DataSet.Tables(</FONT><FONT color=#a31515 size=2>"Detail"</FONT><FONT size=2>).Clear()</FONT> </P>
    <P>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.</P>
  • Replied 8 September 2017, 12:56 pm EST

    <P>Hello,</P>
    <P>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.</P>
Need extra support?

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

Learn More

Forum Channels