none
datagridview SelectionMode

    Question

  • My DataGridView has 3 columns and I have SelectionMode set to FullRowSelect.  If the user double clicks on any cell within a row, I want to add a tab to TabControl.  However, only the 3rd column is responding to the DoubleClick event handler.  The DoubleClick event doesn't have a direct link to the underlying data. Is there an easy way to get to the underlying data from the SelectedRows member of the DataGridView?  The underlying data is a TypedDataSet based on the Products table in the Northwind database.

    Monday, May 19, 2008 3:54 AM

Answers

  • You can use the CellContentClick event and then get whatever you want from any of those columns:

     

    private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
           object value = DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
    }

     

    Monday, May 19, 2008 5:02 AM