我正在尝试使用For … Next循环检查DataGridView中的多个选择,但即使我选择了多行,唯一具有Selected = True属性的行也是选择中的第一行.有没有解决的办法?
MultiSelect在DataGridView上为true.
我的代码如下:
For Each dr As DataGridViewRow In dgv.Rows If dr.Selected = True Then intSelectedRow = dr.Index SetTime("KeyEntry",dgv.Name,intSelectedRow) End If Next
谢谢
试试这个:
原文链接:https://www.f2er.com/vb/255046.htmlDim selectedItems As DataGridViewSelectedRowCollection = dgv.SelectedRows For Each selectedItem As DataGridViewRow In selectedItems 'Add code to handle whatever you want for each row Next End Sub