private void button1_Click(object sender, EventArgs e) { if (textBox2.Text == "") { textBox1.Text = ""; MessageBox.Show("未输入生成计算题数量!"); } else { textBox1.Text = ""; int num; generate gen = new generate(); num = Convert.ToInt32(textBox2.Text); shizi = gen.fun(num); if (checkBox1.CheckState == CheckState.Checked) { for (int i = 0; i < num; i++) { textBox1.Text = textBox1.Text + (i + 1).ToString() + ": " + shizi[i] + Environment.NewLine; } } else { for (int i = 0; i < num; i++) { String[] str = shizi[i].Split('='); textBox1.Text = textBox1.Text + (i + 1).ToString() + ": " + str[0] + '=' + Environment.NewLine; } } } }
//生成按钮点击事件 private void button1_Click(object sender, EventArgs e) { ischanged = false; if (textBox2.Text == "") { textBox1.Text = ""; MessageBox.Show("未输入生成计算题数量!"); } else { textBox1.Text = ""; int num; generate gen = new generate(); num = Convert.ToInt32(textBox2.Text); shizi = gen.fun(num); //显示答案 if (checkBox1.CheckState == CheckState.Checked) { dataGridView1.Rows.Clear(); for (int i = 0; i < num; i++) { String[] str = shizi[i].Split('='); int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = i + 1; this.dataGridView1.Rows[index].Cells[1].Value = str[0] + '='; this.dataGridView1.Rows[index].Cells[2].Value = str[1]; } } //不显示答案 else { dataGridView1.Rows.Clear(); for (int i = 0; i < num; i++) { String[] str = shizi[i].Split('='); int index = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[index].Cells[0].Value = i + 1; this.dataGridView1.Rows[index].Cells[1].Value = str[0] + '='; } } } ischanged = true; }