private void doublecellClick(object sender, DataGridViewCellEventArgs e) { var value = -1; Int32.TryParse(dataGridView1.CurrentCell.FormattedValue.ToString(), out value); if (value > -1 && selectInts.Contains(value)) { selectInts.Remove(value); } if (old != null && !old.Equals(dataGridView1.CurrentCell)) { old.Style.BackColor = Color.White; } dataGridView1.CurrentCell.Style.BackColor = Color.Red; old = dataGridView1.CurrentCell; startNum = value; txtStart.Text = value + ""; txtExcept.Text = string.Join(",", selectInts); dataGridView1.CurrentCell = null; }