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

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

问题描述

这很简单。如何获取 DataGridView 当前选定的的索引?我不想要 Row 对象,我想要索引(0 .. n)。

解决方案

RowIndex 属性为 CurrentCell 属性。

  datagridview.CurrentCell.RowIndex 

处理 SelectionChanged 事件,并找到所选行的索引,如上所述。


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).

解决方案

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

datagridview.CurrentCell.RowIndex

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

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

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