Home:ALL Converter>DeafultcCellStyle format not working on unbound DataGridView C# Winforms

DeafultcCellStyle format not working on unbound DataGridView C# Winforms

Ask Time:2020-02-18T20:39:25         Author:Andy

Json Formatter

I have an unbound DataGridView that I populate with data from an SQL database. One of the columns in the database is of type ‘datetime’.

On the load event of my winforms application, I use code below in order to format the column to only show date part of datetime column. However it shows the full datetime. I want 18/02/2020 and it’s showing 18/02/2020 00:00:00

dgv.Columns["Date"].DefaultCellStyle.Format = "dd/MM/yyyy"
dgv.Columns["Date"].ValueType = typeof(System.DateTime);

How do I format the column to only show the date portion of the datetime column?

Author:Andy,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60281114/deafultccellstyle-format-not-working-on-unbound-datagridview-c-sharp-winforms
yy