Hi All,
Im fetching info from a csv file and importing it in a datatable then a datagridview i'm whising to sort by date but as the info are just stored as strings I need to convert them into dates first the code im using to import the data is as follows
Kind regard tim
Im fetching info from a csv file and importing it in a datatable then a datagridview i'm whising to sort by date but as the info are just stored as strings I need to convert them into dates first the code im using to import the data is as follows
Code:
dt.Columns.Add("Id")
dt.Columns.Add("DateRecieved")
dt.Columns.Add("PartNumber")
dt.Columns.Add("Description")
dt.Columns.Add("SerialNumber")
dt.Columns.Add("Qty")
dt.Columns.Add("RecievedFrom")
dt.Columns.Add("DeliveryNoteNumber")
dt.Columns.Add("PurchaseOrderNumber")
dt.Columns.Add("PaperworkLocation")
dt.Columns.Add("AdditionalPaperworkLocation")
dt.Columns.Add("BookedAgainstLocation")
dt.Columns.Add("StockLocation")
For Each line As String In System.IO.File.ReadAllLines(filename)
' add rows to grid view
dt.Rows.Add(line.Split(","))
Next
Me.DataGridView1.Columns("DateRecieved").DefaultCellStyle.Format = "dd-MMM-yyyy"
Me.DataGridView1.Columns("DateRecieved").ValueType = GetType(DateTime)
DataGridView1.AutoGenerateColumns = False
BindingSource1.DataSource = dt