ISC
asked on
DataGrid Problem
Hi,
I am using a OracleDataAdapter to populate a DataTable.
The DataTable is then linked to DataGridView as a datasource.
The DataGridView is automaticallly populated with data and i have no control over the format of certain columns...
Example: there are date columns where the date is returned from the query in the form YYYYMMDD.
I would like to display date values in the gird as DD/MM/YYYY or MM/DD/YYYY depending on the users local date settting format....
*I have no control over the date format is returned back from the database...
Thnks Ian
I am using a OracleDataAdapter to populate a DataTable.
The DataTable is then linked to DataGridView as a datasource.
The DataGridView is automaticallly populated with data and i have no control over the format of certain columns...
Example: there are date columns where the date is returned from the query in the form YYYYMMDD.
I would like to display date values in the gird as DD/MM/YYYY or MM/DD/YYYY depending on the users local date settting format....
*I have no control over the date format is returned back from the database...
Thnks Ian
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
The following line does not return any format...
Call GetLocaleInfo(GetSystemDef aultLCID, LOCALE_SSHORTDATE, str, Len(str))
Ian
The following line does not return any format...
Call GetLocaleInfo(GetSystemDef
Ian
ASKER
The code below just sets the contents of each cell to the format string which is not what I expected or want...
Private Sub dgv_accrual_periods_CellFo rmatting(B yVal sender As Object, ByVal e As System.Windows.Forms.DataG ridViewCel lFormattin gEventArgs ) Handles dgv_accrual_periods.CellFo rmatting
If (e.ColumnIndex = 1) Or (e.ColumnIndex = 2) Or (e.ColumnIndex = 3) Then
Dim l_objDateFormat As System.Globalization.DateT imeFormatI nfo
l_objDateFormat = System.Threading.Thread.Cu rrentThrea d.CurrentC ulture.Dat eTimeForma t
e.CellStyle.Format = l_objDateFormat.ShortDateP attern.ToS tring
End If
End Sub
Private Sub dgv_accrual_periods_CellFo
If (e.ColumnIndex = 1) Or (e.ColumnIndex = 2) Or (e.ColumnIndex = 3) Then
Dim l_objDateFormat As System.Globalization.DateT
l_objDateFormat = System.Threading.Thread.Cu
e.CellStyle.Format = l_objDateFormat.ShortDateP
End If
End Sub
ASKER
I also tried...
Private Sub dgv_accrual_periods_CellFo rmatting(B yVal sender As Object, ByVal e As System.Windows.Forms.DataG ridViewCel lFormattin gEventArgs ) Handles dgv_accrual_periods.CellFo rmatting
If (e.ColumnIndex = 1) Or (e.ColumnIndex = 2) Or (e.ColumnIndex = 3) Then
Dim l_objDateFormat As System.Globalization.DateT imeFormatI nfo
l_objDateFormat = System.Threading.Thread.Cu rrentThrea d.CurrentC ulture.Dat eTimeForma t
e.Value = String.Format(l_objDateFor mat.ShortD atePattern .ToString, e.Value.ToString)
End If
End Sub
Private Sub dgv_accrual_periods_CellFo
If (e.ColumnIndex = 1) Or (e.ColumnIndex = 2) Or (e.ColumnIndex = 3) Then
Dim l_objDateFormat As System.Globalization.DateT
l_objDateFormat = System.Threading.Thread.Cu
e.Value = String.Format(l_objDateFor
End If
End Sub
DataGridViewColumns.jpg