如何选择一个完整的dataGridView行,当用户点击该行的单元格? [英] How do I select a complete dataGridView Row when the user clicks a cell of that row?
本文介绍了如何选择一个完整的dataGridView行,当用户点击该行的单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个的dataGridView
,我需要当用户点击任意单元格包含该单元格,整个行被选中了。 (它已经多选disbaled)
我试图获得 currentRowIndex
像这样
I have a dataGridView
and I need that when the user clicks on any cell the whole row that contains this cell is selected too. (it has multiselect disbaled)
I tried getting the currentRowIndex
like this
int Index = dataGridView1.CurrentCell.RowIndex;
不过,我不知道怎么用,才能在指数选择该行。 尝试这样做,对其他六种方式,但没有成功:
However, I am not sure how to use the index in order to select that row. Tried this and about other six ways with no success:
dataGridView1.Select(Index);
你知道一个方法可以让我做到这一点?
Do you know a way I can do this?
推荐答案
您需要设置DataGridView中的的SelectionMode
到 FullRowMode
。
You need to set datagridview's SelectionMode
to FullRowMode
.
这篇关于如何选择一个完整的dataGridView行,当用户点击该行的单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文