Replacing a DateTime.MinValue in a DataGridView

后端 未结 8 1772
悲哀的现实
悲哀的现实 2021-01-17 22:42

I am working on a name record application and the information is stored in a SQLite database. All columns in the database are TEXT types, except for the date of birth column

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-17 23:30

    you can cast the object as a DateTime object:

    //create a nullable intermediate variable
    System.DateTime? dtCellValue = resultsGrid.CurrentRow.Cells["DateOfBirth"].Value as System.DateTime?;
    
    //if this cell has been set to String.Emtpy the cast will fail
    //so ensure the intermediate variable isn't null
    if ( dtCellValue.HasValue && dtCellValue == System.DateTime.MinValue )
    //set cell value appropriately
    

提交回复
热议问题