0
如何使它成为我的代码选择数据网格视图中他们单击的行而不是将其硬编码到代码本身中,我想选择用户使用鼠标选择的每一行表格。在Datagridview中选择行
如何使它成为我的代码选择数据网格视图中他们单击的行而不是将其硬编码到代码本身中,我想选择用户使用鼠标选择的每一行表格。在Datagridview中选择行
你必须多选设置为true你的DataGridView和你dataGridView.SelectionMode应该FullRowSelect
例子:
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.MultiSelect = true;
然后你就可以得到
Dim selectedItems As DataGridViewSelectedRowCollection = dataGridView.SelectedRows
For Each selectedItem As DataGridViewRow In selectedItems
'Add code to handle whatever you want for each row
Next
End Sub
选定行