Hi, I have a problem that if I double-click on a datagrid header it returns an error in the CellDoubleClick event, I am interested in the event being valid for all the cells except the headers, I tried with e.RowIndex> 0 or e.RowIndex < > -1 but it does not work, any suggestions ??
I leave the code of what I was testing
private void AgendaSemanal_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (AgendaSemanal.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Libre" && e.RowIndex!=-1)// tambien probe con e.RowIndex>0
{//instrucciones}
}
I also attach the error that is causing me: This is because e.RowIndex is -1 when I double click on the header but I do not understand why it does not let me evaluate it in the IF
Unhandled exception of type 'System.ArgumentOutOfRangeException' in mscorlib.dll Additional information: The index was out of range. It must be a non-negative value and lower than the size of the collection.