在DataGridView中当前所选行的索引 [英] Index of Currently Selected Row in DataGridView

查看:448
本文介绍了在DataGridView中当前所选行的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就这么简单。如何获取当前选定的 A行的DataGridView 的指数?我不想让的对象,我想指数(0 .. N)。

It's that simple. How do I get the index of the currently selected Row of a DataGridView? I don't want the Row object, I want the index (0 .. n).

推荐答案

还有就是<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.rowindex.aspx"><$c$c>RowIndex属性的<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcell.aspx"><$c$c>CurrentCell属性DataGridView的。

There is the RowIndex property for the CurrentCell property for the DataGridView.

datagridview.CurrentCell.RowIndex

处理的<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectionchanged.aspx"><$c$c>SelectionChanged事件,并找到所选择的行的索引如上

Handle the SelectionChanged event and find the index of the selected row as above.

这篇关于在DataGridView中当前所选行的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆