当用户单击该行的单元格时,如何选择完整的dataGridView行? [英] How do I select a complete dataGridView Row when the user clicks a cell of that row?
问题描述
我有一个 dataGridView
,当用户单击任何单元格时,我需要选择包含此单元格的整行。 (它有多重选择disbaled)
我试图获得 currentRowIndex
像这样
int Index = dataGridView1.CurrentCell.RowIndex;
但是,我不知道如何使用索引来选择该行。
尝试这个和其他六种方式没有成功:
dataGridView1.Select(Index);
你知道一种方法吗?
您需要将datagridview的 SelectionMode
设置为 FullRowMode
/ p>
注意:在具有.NET 4.5的Visual Studio 2013中,该属性称为 FullRowSelect
,请参阅 https://msdn.microsoft.com/en-us/library/3c89df86( v = vs.110).aspx
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?
You need to set datagridview's SelectionMode
to FullRowMode
.
Note: In Visual Studio 2013 with .NET 4.5 the property is called FullRowSelect
, see https://msdn.microsoft.com/en-us/library/3c89df86(v=vs.110).aspx
这篇关于当用户单击该行的单元格时,如何选择完整的dataGridView行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!