Um.
if (productionDataGridView.SelectedRows.Count <= 1)
{
MessageBox.Show("Please select the first item in list");
}
So if he selects anything, the count will be one or more regardless of the row he selects...
Plus, Double click isn't the only way to select a row: a single click will do it, as will a single click followed by CTRL and a second row single click, or ...
Instead, handle the SelectionChanged event:
private void myDataGridView_SelectionChanged(object sender, EventArgs e)
{
DataGridView dgv = sender as DataGridView;
if (dgv != null)
{
DataGridViewSelectedRowCollection selected = dgv.SelectedRows;
if (selected.Count != 1 || selected[0].Index != 0)
{
dgv.ClearSelection();
}
}
}
And the user can't select anything except the first row.