vb.net 数据插入datagridview的指定列!
有个dataguidview控件,里面已经绑定并显示数据,想跳出输入框,输入某个数字如123,123就插入datagridview的第二列的第一行,后继每行以+11的形式...
有个dataguidview控件,里面已经绑定并显示数据,想跳出输入框,输入某个数字如123 ,123就插入datagridview的第二列的第一行,后继每行以+11的形式插入,如124 125 126 ,实际运行后,除了第一行,别的数据都插入成功,我的代码如下,麻烦高手指定下菜鸟!谢谢
Dim n1 As String
n1 = InputBox("请输入数字")
Dim i1 As Integer '行数
Dim Myi1 As Integer = datagridview1.RowCount '获取总行数
Dim m1 As String '标记算出来的值
i1 = 1
datagridview1.Rows(0).Cells(1).Value = n1
m1 = n1
For i1 = i1 To Myi1
m1 = m1 + 1 '算出每行的数据
datagridview1.Rows(i1).Cells(1).Value = m1
'
If i1 >= Myi1 - 1 Then Exit For
Next
Dim SCB1 = New SqlCommandBuilder(dataAdapter)
For Each csDataRow As DataRow In dt.Rows
csDataRow.Item("单据状态") = "已打印"
csDataRow.Item("打印时间") = System.DateTime.Now
dataAdapter.Update(dt)
Next 展开
Dim n1 As String
n1 = InputBox("请输入数字")
Dim i1 As Integer '行数
Dim Myi1 As Integer = datagridview1.RowCount '获取总行数
Dim m1 As String '标记算出来的值
i1 = 1
datagridview1.Rows(0).Cells(1).Value = n1
m1 = n1
For i1 = i1 To Myi1
m1 = m1 + 1 '算出每行的数据
datagridview1.Rows(i1).Cells(1).Value = m1
'
If i1 >= Myi1 - 1 Then Exit For
Next
Dim SCB1 = New SqlCommandBuilder(dataAdapter)
For Each csDataRow As DataRow In dt.Rows
csDataRow.Item("单据状态") = "已打印"
csDataRow.Item("打印时间") = System.DateTime.Now
dataAdapter.Update(dt)
Next 展开
1个回答
展开全部
Dim n1 As String
n1 = InputBox("请输入数字")
Dim i As Integer '行数
datagridview1.Rows(0).Cells(1).Value = n1
For i = 1 To datagridview1.Rows.count-1
n1=n1+1
datagridview1.Rows(i).Cells(1).Value = n1
Next
......
n1 = InputBox("请输入数字")
Dim i As Integer '行数
datagridview1.Rows(0).Cells(1).Value = n1
For i = 1 To datagridview1.Rows.count-1
n1=n1+1
datagridview1.Rows(i).Cells(1).Value = n1
Next
......
追问
测试了下单独datagridview1.Rows(0).Cells(1).Value = "1234567" 无法更新到数据库
datagridview1.Rows(1).Cells(1).Value = "1234567"
等等都可以更新,就第一行的无法更新,不知道是什么原因了!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询