How do I format datagrid column to short time?

  • Thread starter Thread starter Me
  • Start date Start date
M

Me

In my VB.Net program I am populatating a datagrid column using an MS Access
database field that that contains data formated in "Short Time" (17:34).
Right now, the datagrid displays the entire date and time. I need only the
short time. How can I do this simply?
I dont't use ASP.

Thanks,

Gigi
 
Use the Format property of the DataGridTextBoxColumn. You
need to add a TableStyle to the DataGrid.

Jan
 
if you are using an sql statement to get your data you can format your time
field directly in the statement
CONVERT(VARCHAR(5),tblIngaveDetail.indBeginuur,8) AS StartTime

using tablestyles can be confusing at first have a look at the following
code

dsform = New DataSet("data")

dsform = SqlHelper.ExecuteDataset(gstrCnn, CommandType.Text, strSql)

Dim ts As New DataGridTableStyle

ts.MappingName = "Table"

dgrMain.TableStyles.Clear()

dgrMain.SetDataBinding(dsform, "Table")

dgrMain.TableStyles.Add(ts)

ts.GridColumnStyles(0).Width = 0

ts.GridColumnStyles(1).Width = 40

ts.GridColumnStyles(2).Width = 87

ts.GridColumnStyles(3).Width = 50

ts.AllowSorting = True

ts.AlternatingBackColor = Color.Lavender

ts.BackColor = Color.WhiteSmoke

ts.ForeColor = Color.MidnightBlue

ts.GridLineColor = Color.Gainsboro

ts.HeaderBackColor = Color.MidnightBlue

ts.HeaderForeColor = Color.WhiteSmoke

ts.LinkColor = Color.Navy

ts.SelectionBackColor = Color.Navy

ts.SelectionForeColor = Color.Lavender

ts.ColumnHeadersVisible = True
 
Back
Top