mac-duff
May 7th, 2010, 06:49 AM
Hi,
I ve connected or better created with the datasource a DataGrid where I have in one column seconds. This seconds I want to display in the format hh:mm:ss.
Fot his I can use this code
Dim t As New TimeSpan(0, 0, row.Cells(DataGridViewTextBoxColumn6.Index).Value)
but eerytime when I try to write it back I get the error that I just can write int32 and I also tried to change it with the DefaultSytle but without luck
Private Sub ConvertTime()
DataGridViewTextBoxColumn6.DefaultCellStyle.ToString()
For Each row As DataGridViewRow In ProduccionDataGridView.Rows
If row.Cells(DataGridViewTextBoxColumn6.Index).Value Is DBNull.Value = False Then
Dim t As New TimeSpan(0, 0, row.Cells(DataGridViewTextBoxColumn6.Index).Value)
'row.Cells(DataGridViewTextBoxColumn6.Index).Style.Format = "HH:mm:ss"
'row.Cells(DataGridViewTextBoxColumn6.Index).ToString()
row.Cells(DataGridViewTextBoxColumn6.Index).Value = (t.Hours & ":" & t.Minutes & ":" & t.Seconds).ToString
'row.Cells(DataGridViewTextBoxColumn6.Index).Value = DateAndTime
'row.Cells(DataGridViewTextBoxColumn6.Index).Value = t.Hours & t.Minutes & t.Seconds
End If
Next
End Sub
Can please someone give me a hint how to solve it?
Thanks
Stephan
I ve connected or better created with the datasource a DataGrid where I have in one column seconds. This seconds I want to display in the format hh:mm:ss.
Fot his I can use this code
Dim t As New TimeSpan(0, 0, row.Cells(DataGridViewTextBoxColumn6.Index).Value)
but eerytime when I try to write it back I get the error that I just can write int32 and I also tried to change it with the DefaultSytle but without luck
Private Sub ConvertTime()
DataGridViewTextBoxColumn6.DefaultCellStyle.ToString()
For Each row As DataGridViewRow In ProduccionDataGridView.Rows
If row.Cells(DataGridViewTextBoxColumn6.Index).Value Is DBNull.Value = False Then
Dim t As New TimeSpan(0, 0, row.Cells(DataGridViewTextBoxColumn6.Index).Value)
'row.Cells(DataGridViewTextBoxColumn6.Index).Style.Format = "HH:mm:ss"
'row.Cells(DataGridViewTextBoxColumn6.Index).ToString()
row.Cells(DataGridViewTextBoxColumn6.Index).Value = (t.Hours & ":" & t.Minutes & ":" & t.Seconds).ToString
'row.Cells(DataGridViewTextBoxColumn6.Index).Value = DateAndTime
'row.Cells(DataGridViewTextBoxColumn6.Index).Value = t.Hours & t.Minutes & t.Seconds
End If
Next
End Sub
Can please someone give me a hint how to solve it?
Thanks
Stephan