C# datagridview doubleclick on row with FullRowSelect

cdatagridviewdouble-clickevents

I have a datagridview in my C# application and the user should only be able to click on full rows. So I set the SelectionMode to FullRowSelect.

But now I want to have an Event which is fired when the user double clicks on a row. I want to have the row number in a MessageBox.

I tried the following:

 this.roomDataGridView.CellContentDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.roomDataGridView_CellCont‌ ​entDoubleClick); 

 private void roomDataGridView_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
      MessageBox.Show(e.RowIndex.ToString());
 }

Unforunately nothing happens. What am I doing wrong?

Best Answer

In CellContentDoubleClick event fires only when double clicking on cell's content. I used this and works:

    private void dgvUserList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
    {
        MessageBox.Show(e.RowIndex.ToString());
    }
Related Topic