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

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

问题描述

就是这么简单.如何获取 DataGridView 的当前选定的 Row 的索引?我不想要 Row 对象,我想要索引 (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).

推荐答案

RowIndex 属性用于 CurrentCell DataGridView 的属性.

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

datagridview.CurrentCell.RowIndex

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

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

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

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