Problem with Datatable Insert
- From: "simchajoy2000@xxxxxxxxx" <simchajoy2000@xxxxxxxxx>
- Date: 4 Oct 2006 12:54:59 -0700
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(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim tbl As DataTable = New DataTable
Dim row As DataRow = tsTbl.NewRow
Dim i As Integer
Dim dt As Date
If tsTbl.Rows.Count > 0 And ClickHti.Row > 0 Then
row2 = tsTbl.Rows(ClickHti.Row - 1)
row3 = tsTbl.Rows(ClickHti.Row)
dt = Get_NextStartDate(row2(0))
Else
dt = StartDate
End If
row(0) = dt
row(1) = Get_EndDate(row(0), "date")
For i = 2 To tsTbl.Columns.Count - 1
row(i) = 0
Next
tsTbl.Rows.InsertAt(row, ClickHti.Row)
tsTbl.AcceptChanges()
dgTime.ReadOnly = False
'dgTime.DataSource = 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
.
- Prev by Date: Compiling .dll's into a stand-alone .exe
- Next by Date: Re: Compiling .dll's into a stand-alone .exe
- Previous by thread: Compiling .dll's into a stand-alone .exe
- Next by thread: VB6 --> VB 2005 upgrade ...IDE now VERY slow!!!
- Index(es):
Relevant Pages
|