private void buttonOK_Click(object sender, EventArgs e) { if (this.dataGridView1.Rows.Count < 3) // auto last row { Mbox.ShowSimpleMsgBoxError("You must provide at least 2 choices!"); return; } int last = this.dataGridView1.Rows.Count -1; foreach (DataGridViewRow row in this.dataGridView1.Rows) { // Last row is added automatically if (row == this.dataGridView1.Rows[last]) continue; DataGridViewCell c = row.Cells[0]; if (string.IsNullOrWhiteSpace((string)c.Value)) { Mbox.ShowSimpleMsgBoxError("You must enter data in each cell!"); return; } c = row.Cells[1]; if (string.IsNullOrWhiteSpace((string)c.Value)) { Mbox.ShowSimpleMsgBoxError("You must enter data in each cell!"); return; } } // OK foreach (DataGridViewRow row in this.dataGridView1.Rows) { if (row == this.dataGridView1.Rows[last]) continue; responseFixedItem item = new OpenDoPEModel.responseFixedItem(); item.value = (string)row.Cells[0].Value; item.label = (string)row.Cells[1].Value; responseFixed.item.Add(item); } if (this.radioButtonYes.Checked) { responseFixed.canSelectMany = true; } else { responseFixed.canSelectMany = false; } responseFixed.canSelectManySpecified = true; // have to set this! this.Close(); }
private void buttonOK_Click(object sender, EventArgs e) { if (this.dataGridView1.Rows.Count < 3) // auto last row { Mbox.ShowSimpleMsgBoxError("You must provide at least 2 choices!"); return; } int last = this.dataGridView1.Rows.Count - 1; foreach (DataGridViewRow row in this.dataGridView1.Rows) { // Last row is added automatically if (row == this.dataGridView1.Rows[last]) { continue; } DataGridViewCell c = row.Cells[0]; if (string.IsNullOrWhiteSpace((string)c.Value)) { Mbox.ShowSimpleMsgBoxError("You must enter data in each cell!"); return; } c = row.Cells[1]; if (string.IsNullOrWhiteSpace((string)c.Value)) { Mbox.ShowSimpleMsgBoxError("You must enter data in each cell!"); return; } } // OK foreach (DataGridViewRow row in this.dataGridView1.Rows) { if (row == this.dataGridView1.Rows[last]) { continue; } responseFixedItem item = new OpenDoPEModel.responseFixedItem(); item.value = (string)row.Cells[0].Value; item.label = (string)row.Cells[1].Value; responseFixed.item.Add(item); } if (this.radioButtonYes.Checked) { responseFixed.canSelectMany = true; } else { responseFixed.canSelectMany = false; } responseFixed.canSelectManySpecified = true; // have to set this! this.Close(); }