private void simpleButton1_Click(object sender, EventArgs e) { listChoosedYears.Clear(); for (int i = 0; i < gridView1.RowCount; i++) { if ((bool)gridView1.GetRowCellValue(i, "B")) { ChoosedYears cy = new ChoosedYears(); cy.Year = Convert.ToInt32(gridView1.GetRowCellValue(i, "A").ToString().Replace("年", "")); cy.WithIncreaseRate = (bool)gridView1.GetRowCellValue(i, "C"); listChoosedYears.Add(cy); } } if (listChoosedYears.Count < 2) { MsgBox.Show("请至少选择 2 个年份!"); return; } //在需要增长率的条件下,最后一个年份,自动设置为带增长率 if (!_noIncreaseRate) { listChoosedYears[listChoosedYears.Count - 1].WithIncreaseRate = true; } DialogResult = DialogResult.OK; }
private void simpleButton1_Click(object sender, EventArgs e) { listChoosedYears.Clear(); for (int i = 0; i < gridView1.RowCount; i++) { if ((bool)gridView1.GetRowCellValue(i, "B")) { ChoosedYears cy = new ChoosedYears(); cy.Year = Convert.ToInt32(gridView1.GetRowCellValue(i, "A").ToString().Replace("年", "")); cy.WithIncreaseRate = (bool)gridView1.GetRowCellValue(i, "C"); listChoosedYears.Add(cy); } } if (listChoosedYears.Count < 2) { MsgBox.Show("请至少选择 2 个年份!"); return; } //在需要增长率的条件下,最后一个年份,自动设置为带增长率 if(!_noIncreaseRate) { listChoosedYears[listChoosedYears.Count - 1].WithIncreaseRate = true; } DialogResult = DialogResult.OK; }