My date format in datagridview column is not changing.

dobrypoznaccos

New member
Joined
May 29, 2012
Messages
1
Programming Experience
Beginner
Hi
I have a datagridview populated using a csv file. I have a column named Date. The csv file has mixup of different date formats. So I need the date column in datagridview to be in standard "MM-dd-yyyy" format. I used below code
VB.NET:
 Me.dataGridView1.Columns("Date").DefaultCellStyle.Format = "d"
It didnot have any impact.
So I used the below shown code
VB.NET:
Me.dataGridView1.Columns("Date").DefaultCellStyle.Format = "MM-dd-yyyy"
Still no effect.
I am confused. Can anyone help me on this... Please.
 
I think I already answered this on another forum but here goes again. Date formatting specifiers are only applicable to DateTime values, not Strings. It's up to you to convert your Strings to DateTimes first. You can then display them in the grid and it will format them for you.
 
Back
Top