Hi,
I am experiencing a strange problem when inserting rows in a datatable
that is attached to a datagrid. I have made it so that when the user
right clicks on a row the context menu item "Insert Row" pops up. The
event handler code for when they click on this menu item is as follows:
Private Sub Insert_Row(ByVa l sender As Object, ByVal e As
System.EventArg s)
Dim tbl As DataTable = New DataTable
Dim row As DataRow = tsTbl.NewRow
Dim i As Integer
Dim dt As Date
If tsTbl.Rows.Coun t 0 And ClickHti.Row 0 Then
row2 = tsTbl.Rows(Clic kHti.Row - 1)
row3 = tsTbl.Rows(Clic kHti.Row)
dt = Get_NextStartDa te(row2(0))
Else
dt = StartDate
End If
row(0) = dt
row(1) = Get_EndDate(row (0), "date")
For i = 2 To tsTbl.Columns.C ount - 1
row(i) = 0
Next
tsTbl.Rows.Inse rtAt(row, ClickHti.Row)
tsTbl.AcceptCha nges()
dgTime.ReadOnly = False
'dgTime.DataSou rce = tsTbl
dgTime.Refresh( )
End Sub
After thise code completes everything appears fine until the user tries
to edit one of the cells in the newly added row. When they attempt to
change the value from 0 to 50 for example and then click away from the
cell, the cell value reverts back to 0. I have no idea what the
problem could be - can someone clue me in?
Thanks!
Joy
I am experiencing a strange problem when inserting rows in a datatable
that is attached to a datagrid. I have made it so that when the user
right clicks on a row the context menu item "Insert Row" pops up. The
event handler code for when they click on this menu item is as follows:
Private Sub Insert_Row(ByVa l sender As Object, ByVal e As
System.EventArg s)
Dim tbl As DataTable = New DataTable
Dim row As DataRow = tsTbl.NewRow
Dim i As Integer
Dim dt As Date
If tsTbl.Rows.Coun t 0 And ClickHti.Row 0 Then
row2 = tsTbl.Rows(Clic kHti.Row - 1)
row3 = tsTbl.Rows(Clic kHti.Row)
dt = Get_NextStartDa te(row2(0))
Else
dt = StartDate
End If
row(0) = dt
row(1) = Get_EndDate(row (0), "date")
For i = 2 To tsTbl.Columns.C ount - 1
row(i) = 0
Next
tsTbl.Rows.Inse rtAt(row, ClickHti.Row)
tsTbl.AcceptCha nges()
dgTime.ReadOnly = False
'dgTime.DataSou rce = tsTbl
dgTime.Refresh( )
End Sub
After thise code completes everything appears fine until the user tries
to edit one of the cells in the newly added row. When they attempt to
change the value from 0 to 50 for example and then click away from the
cell, the cell value reverts back to 0. I have no idea what the
problem could be - can someone clue me in?
Thanks!
Joy