Home Forums WinForms controls Xceed Grid for WinForms Date value of 0001-01-01 displays as Null

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17613 |

    I have a grid column defined as DateTime. If I attempt to set a cell to a value of 0001-01-01 (eg. 1st of January 0001) then the value displays as Null.

    My code is:

    c.Value = CDate(dataval)         ‘ dataval is a string variable with value ‘0001-01-01’

    At the end of this:

    c.Value is Date: #12:00:00 AM#

    c.GetDisplayText is “NULL”     (which is the value of c.NullText)

    0001-01-01 is a valid date and should display OK in the grid.

    Phil. 

     

     

    Imported from legacy forums. Posted by Phil (had 1898 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Phil,

    You can set the NullText value on the Column so that it will reflect the minimum value. In the following code, the column will display your desired output.

    ———-

                DateTime dt = new DateTime();
                dt.AddDays(1d);
                dt.AddMonths(1);
                dt.AddYears(1); 

                this.gridControl1.BeginInit();
               
                this.gridControl1.Columns[“Column7”].NullText = dt.ToString();

                this.gridControl1.EndInit();

    ———-

    Imported from legacy forums. Posted by Marc [Xceed] (had 1225 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.