Replacing a DateTime.MinValue in a DataGridView

后端 未结 8 1621
悲哀的现实
悲哀的现实 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

    private void resultsGrid_DateFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
    {
        if(resultsGrid.Columns[e.ColumnIndex].Name.Equals("DateOfBirth"))
    {
        if ((string)resultsGrid.CurrentRow.Cells["DateOfBirth"].Value == DateTime.MinValue.ToString())
        {
             // Set cell value to ""
        }
    }
    

    }

    Or you might have to cast to DateTime and then compare to MinValue, but it sounds like you have the right idea.

提交回复
热议问题