Bim*_*mal 1 .net datagridview cell
我的表单中有一个DataGridView.功能如下.
我已将multiselect设置为true.我可以使用鼠标选择多个单元格.但我想以编程方式进行.
如果你的multiselect为true,DataGridView那么你可以遍历网格并将所需的行设置为Selected
(也是你的dataGridView.SelectionMode应该FullRowSelect)
dataGridView.Rows[0].Selected = true;//determine index value from your logic
dataGridView.Rows[5].Selected = true;
Run Code Online (Sandbox Code Playgroud)
编辑
而不是行选择然后您可以尝试此逻辑,订阅rowheaderclick事件,其中您将获得单击它的行索引,现在循环列并将每个单元格设置为选定(类似于上面)
对于HeaderClick事件,以相同的方式,您可以使用列索引,现在以行方式循环并设置所选的行索引.
datagridview1[columnindex, rowindex].Selected = true
Run Code Online (Sandbox Code Playgroud)
对于行,rowindex将被固定,而对于列选择,columnindex将是固定的.
希望这对你有所帮助.
| 归档时间: |
|
| 查看次数: |
11066 次 |
| 最近记录: |