Index of Currently Selected Row in DataGridView

后端 未结 12 1802
误落风尘
误落风尘 2020-11-28 22:46

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 in

12条回答
  •  北海茫月
    2020-11-28 23:12

    I used if get row value is clicked:

    private void dataGridView_Product_CellClick(object sender, DataGridViewCellEventArgs e){
        int rowIndex;
        //rowIndex = e.RowIndex; //Option 1
        //rowIndex= dataGridView_Product.CurrentCell.RowIndex; //Option 2
        rowIndex = dataGridView_Product.CurrentRow.Index; //Option 3
    }
    

提交回复
热议问题