S
Sam
Hi all
I have a simple datagrid form which has 4 columns. The first one is used
just like a key and the other threes allow user to enter numbers. The
problem that I am having is that when I click on a cell of a new row but
decide not to enter a value and go back to any of the previous rows for
editting or whatever reason, the value of the new row will be incremented by
value of the AutoIncrementStep
Here is the problem I have
When I loaded the table for a first time, the first row has a value of 0 in
column 1. I then entered 5, 5, 5 in column 2, 3, and 4 respectively. I
clicked on the 2nd row (new row), a new value of 1 was in column 1
(everything is fine up to this point). Instead entering values for column 2,
3 and 4, I went back to my row 1 to edit the data. I then came back to my
second row and enter values for my columns 2, 3 and 4. I noticed that the
value of row 2 is now 2 not 1 and it seems like the number keeps on
incrementing.
Can we make the number increment only when an actual new row is created ? I
have included the code for column 1, all others are pretty much the same.
Dim mInputTable As New DataTable
Dim IDColStyle As New DataGridTextBoxColumn
Dim mIDCol As New DataColumn
'Initialize node column
mIDCol.ColumnName = "Node ID"
mIDCol.Caption = "Node ID"
mIDCol.AutoIncrement = True
mIDCol.AutoIncrementSeed = 0
mIDCol.AutoIncrementStep = 1
mIDCol.DataType = GetType(Integer)
IDColStyle.MappingName = "Node ID"
IDColStyle.NullText = ""
IDColStyle.Width = 72
IDColStyle.ReadOnly = True
IDColStyle.HeaderText = mIDCol.Caption
TableStyle.GridColumnStyles.Add(IDColStyle)
dgdInput.TableStyles.Add(TableStyle)
dgdInput.DataSource = mInputTable
I have a simple datagrid form which has 4 columns. The first one is used
just like a key and the other threes allow user to enter numbers. The
problem that I am having is that when I click on a cell of a new row but
decide not to enter a value and go back to any of the previous rows for
editting or whatever reason, the value of the new row will be incremented by
value of the AutoIncrementStep
Here is the problem I have
When I loaded the table for a first time, the first row has a value of 0 in
column 1. I then entered 5, 5, 5 in column 2, 3, and 4 respectively. I
clicked on the 2nd row (new row), a new value of 1 was in column 1
(everything is fine up to this point). Instead entering values for column 2,
3 and 4, I went back to my row 1 to edit the data. I then came back to my
second row and enter values for my columns 2, 3 and 4. I noticed that the
value of row 2 is now 2 not 1 and it seems like the number keeps on
incrementing.
Can we make the number increment only when an actual new row is created ? I
have included the code for column 1, all others are pretty much the same.
Dim mInputTable As New DataTable
Dim IDColStyle As New DataGridTextBoxColumn
Dim mIDCol As New DataColumn
'Initialize node column
mIDCol.ColumnName = "Node ID"
mIDCol.Caption = "Node ID"
mIDCol.AutoIncrement = True
mIDCol.AutoIncrementSeed = 0
mIDCol.AutoIncrementStep = 1
mIDCol.DataType = GetType(Integer)
IDColStyle.MappingName = "Node ID"
IDColStyle.NullText = ""
IDColStyle.Width = 72
IDColStyle.ReadOnly = True
IDColStyle.HeaderText = mIDCol.Caption
TableStyle.GridColumnStyles.Add(IDColStyle)
dgdInput.TableStyles.Add(TableStyle)
dgdInput.DataSource = mInputTable