且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

DataGridView中当前所选行的索引

更新时间:2023-01-27 18:19:49

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.