I have a SQLite database and I store dates as ISO 8601 formatted strings ("yyyy-MM-dd HH:mm:ss").
I have bound one of the tables from this database to a DataGridView control (dgvFuel) using a Relation (Vehicle_Fuel).
I would like to show the date field values in the grid as DateTime values ("M/d/yyyy"), not string values.Code:With bsFuel .DataSource = Nothing .DataMember = "Vehicle_Fuel" .DataSource = bsVehicles .Sort = "VehicleID, Odometer, RecDate" End With dgvFuel.DataSource = bsFuel
The column that has the date field in the grid is configured as follows:
The DefaultCellStyle.Format property of the DataGridViewTextBoxColumn does not show the date as a DateTime data type.Code:tbc = New DataGridViewTextBoxColumn With tbc .DataPropertyName = "RecDate" .Name = "RecDate" .HeaderText = "Date" .DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter .DefaultCellStyle.Format = "M/d/yyyy" .AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells .SortMode = DataGridViewColumnSortMode.Automatic End With .Columns.Add(tbc)
What do I need to do to show the dates as DateTime values in my DataGridView?




Reply With Quote
