private DataGridViewRowUpgrade FindRow(Host host) { foreach (DataGridViewRowUpgrade row in dataGridView1.Rows) { if (host == null && row.Host == null) return row; if (host != null && row.Host != null && host.Equals(row.Host)) return row; } throw new Exception("Row not found"); }