I have a datagridvied with several columns and one with date and the format is
Me.DataGridView1.Columns("Doopdatum").DefaultCellStyle.Format = "yyyy - MM - dd dddd"
or
Me.DataGridView1.Columns("Doopdatum").DefaultCellStyle.Format = "dddd dd - MM - yyyy"
Depends on the button i press
My problem is when i reverse from "yyyy - MM - dd dddd" to "dddd dd - MM - yyyy" It dos not work proper
I have the folowing code to reverse the date
Private Sub DoopdatumOmdraaienToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DoopdatumOmdraaienToolStripMenuItem.Click
If DoopdatumOmdraaienToolStripMenuItem.CheckState = CheckState.Checked Then
Me.DataGridView1.Columns("Doopdatum").DefaultCellStyle.Format = "dddd dd - MM - yyyy"
For Each row As DataGridViewRow In DataGridView1.Rows
Dim date1 As Date = row.Cells(5).Value
row.Cells(5).Value = Format(date1.ToString("dddd dd - MM - yyyy"))
Next
With My.Settings
.Setting25 = True
My.Settings.Save()
End With
End If
If DoopdatumOmdraaienToolStripMenuItem.CheckState = CheckState.Unchecked Then
Me.DataGridView1.Columns("Doopdatum").DefaultCellStyle.Format = "yyyy - MM - dd dddd"
For Each row As DataGridViewRow In DataGridView1.Rows
Dim date1 As Date = row.Cells(5).Value
row.Cells(5).Value = Format(date1.ToString("yyyy - MM - dd dddd"))
Next
With My.Settings
.Setting25 = False
My.Settings.Save()
End With
End If
End Sub
My outut gives the following when it is in dddd dd MM yyyy.
1111 - 01 - 31 Dinsdag
1111 - 01 - 04 Zaterdag
Donderdag 05 - 01 - 1111
and so on
What am i doing wrong
I tried everything Please help