C# – How to Disable Double Click on the Header of a DataGridView

cdatagridviewwinforms

I want to do some stuff while double click on a Gridview (Row) not single cell. Means on a double click event handler not on MouseDoubleClick event. But i am not able to disable the header column and row double click event..and also want to load data to combobox(ComboBox is on the same form) when i double click on the GridView Row. Help me Please..!!!

private void gvLoadAllData_DoubleClick(object sender, EventArgs e)
{
    if()
    {
        //Do Something
    }
}

Best Answer

I already had CellDoubleClick event defined and doing stuff, my issue was that a double click on the header was firing that event and therefore crashing the app.

Taking Disaster's idea, I just added the following to get around that event.

if (e.RowIndex == -1) 
    return;
Related Topic