private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { // If clicking the header row, than we won't have a data row. if (e.RowIndex == -1) { return; } DataGridViewRow row = dataGridView1.Rows[e.RowIndex]; int taskID = (int)row.Cells[0].Value; TaskRunEntity run = model.runs[taskID]; //DataGridViewCell cell = row.Cells[e.ColumnIndex]; if (e.Button == MouseButtons.Left) { // If the entity is already highlighted // but not in the model.selection context, then force // it to be selected if (row.Selected && model.selection.current.SelectedEntity != run) { suppress_selection_notify = true; try { model.selection.Update(this, run); } finally { suppress_selection_notify = false; } } } else if (e.Button == MouseButtons.Right) { PopupMenu.ShowContextMenu(contextMenuStrip1, run); } }