I am using a DGV Object, which I initially bind its DataSource to a DataTable. After binding, I run a "FormatGrid()" method which format the columns of the grid. One command I do is the following:
If gridStudents.Columns.Contains("DOB") Then
With gridStudents
.Columns("DOB").HeaderText = "DOB"
.Columns("DOB").Width = objGraphics.MeasureString("XX/XX/XXXX", objFont).Width + 15
.Columns("DOB").DisplayIndex = 3
.Columns("DOB").CellTemplate.Style.Format = "MM/dd/yyyy"
End With
End If
Now, the above code works perfectly...the first time. But later, if I reload the data in the DataTable, which I then unbind and rebind the DataSource and call the FormatGrid() method again, the "MM/dd/yyyy" format will not apply itself. It defaults to the mormal date display.
Anyone know what I am doing wrong or how to force the DGV to display the Date format as I want it to?
________________________
Ben Santiago, MCP & A+
Programmer Analyst (SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS)
Eastern Suffolk BOCES - Student Data Services
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
-Rich Cook