如何移动到vb.net中datagridview的下一行 [英] how to move to next row in datagridview in vb.net
本文介绍了如何移动到vb.net中datagridview的下一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有datagridview,其中包含12列。最后3列是种姓,教授,学位,这些是组合柱。我正在更改这些comboboxcolumn值以将其保存到数据库中。
在cellvalue更改事件时,我正在编写以下代码:
I have datagridview which contains 12 columns.Last 3 columns are caste,prof,degree and these are comboboxcolumn. I am changing these comboboxcolumn values to save it into database.
On cellvalue changed event,I am writing following code:
If e.ColumnIndex = 9 Then
If Me.dgvUserDetails.Rows(e.RowIndex).Cells(9).Value.ToString <> "" Then
caste = Me.dgvUserDetails.Rows(e.RowIndex).Cells(9).Value.ToString
sql = "Select ID from Category where Desc = ''" & caste & "''"
If rs.State = 1 Then rs.Close()
rs.Open(sql, MainCon, 1, 3)
If Not rs.EOF Then
C_Id = rs.Fields(0).Value
End If
End If
ElseIf e.ColumnIndex = 10 Then
If Me.dgvUserDetails.Rows(e.RowIndex).Cells(10).Value.ToString <> "" Then
prof = Me.dgvUserDetails.Rows(e.RowIndex).Cells(10).Value.ToString
sql = "Select ID from Category where Desc = ''" & prof & "''"
If rs.State = 1 Then rs.Close()
rs.Open(sql, MainCon, 1, 3)
If Not rs.EOF Then
P_Id = rs.Fields(0).Value
End If
End If
ElseIf e.ColumnIndex = 11 Then
If Me.dgvUserDetails.Rows(e.RowIndex).Cells(11).Value.ToString <> "" Then
degree = Me.dgvUserDetails.Rows(e.RowIndex).Cells(11).Value.ToString
sql = "Select ID from Category where Desc = ''" & degree & "''"
If rs.State = 1 Then rs.Close()
rs.Open(sql, MainCon, 1, 3)
If Not rs.EOF Then
D_Id = rs.Fields(0).Value
End If
End If
End If
我想用循环来移动到下一行。如何使用它?
I want to use for loop to move to next row.How to use it?
推荐答案
http://www.vbforums.com/showthread.php?513426-RESOLVED-select-next-row-in-datagridview [ ^ ]
http://thehouseofvb.wordpress.com/2010/11/21/move-to-next-datagridview-row-via-code/ [ ^ ]
这篇关于如何移动到vb.net中datagridview的下一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文