vb.net – DataGridView多行选择问题
发布时间:2020-12-17 00:32:54 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用For … Next循环检查DataGridView中的多个选择,但即使我选择了多行,唯一具有Selected = True属性的行也是选择中的第一行.有没有解决的办法? MultiSelect在DataGridView上为true. 我的代码如下: For Each dr As DataGridViewRow In dgv.Rows
我正在尝试使用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 谢谢
试试这个:
Dim 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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |