private void monthYearChoosen(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { DataGridViewTextBoxCell cell = (DataGridViewTextBoxCell)monthYear.Rows[e.RowIndex].Cells[e.ColumnIndex]; if (cell.Value != null) { CurrentYear = Convert.ToInt32(cell.Value); var monthsfromYear = mc.GetMonthsWithVisits("" + cell.Value); months.Clear(); foreach (var item in monthsfromYear) { months.Add(new StringValue("" + item)); } } } }