brokeMyLegBiking
asked on
change datagrid column display format
I am displaying data using a datagrid. However, when I display a datetime field from MS SQLserver, it only displays the date, and not the time.
Is there a way to change the format of a column in a datagrid so that both the date and the time are displayed?
-brokeMyLegBiking
ASKER
that seems like a lot of lines of code just to change the format for one column.
I don't quite understand what the code is doing here. Is it reading in a table that contains styles for each column?
I don't quite understand what the code is doing here. Is it reading in a table that contains styles for each column?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim myGridTableStyle As DataGridTableStyle = New DataGridTableStyle
myGridTableStyle.MappingNa
DataGrid1.TableStyles.Clea
DataGrid1.TableStyles.Add(
'ColumnNumber1 is the datetime column number
Dim myTextBoxColumn1 As DataGridTextBoxColumn = DataGrid1.TableStyles(0).G
myTextBoxColumn1.Format = "yyyy/MM/dd HH:mm:ss"
If you are using table style, just add myTextBoxColumn1.Format = "yyyy/MM/dd HH:mm:ss" to that column.