我的任务是创建一个计划表单,我必须在每个指定的日期在一列或数据中添加多个文本。
我遇到的问题是它只能为多列添加一行。
我需要做的是为每列添加多行数据。
以下是代码的一部分:
private void button1_Click_1(object sender, EventArgs e)
{
//dgv1.Rows.Add(1);
if (comboBox1.Text == "Monday")
{
DataGridViewRow row = dgv1.Rows[rowcount];
row.Height = 60;
grpclassname = textBox1.Text;
txtinst = cmbInstructor.Text;
txtdesc = textBox3.Text;
txtFull = grpclassname + "\n" + txtinst + "\n" + txtdesc;
dgv1.Rows[rowcount].Cells[0].Value =
tp1.Value.ToShortTimeString() + " - " + tp2.Value.ToShortTimeString();
dgv1.Rows[rowcount].Cells[1].Value = txtFull;
//rowcount++;
//dgv1.Rows.Add(1);
}
else if (comboBox1.Text == "Tuesday")
{
DataGridViewRow row = dgv1.Rows[rowcount];
row.Height = 60;
grpclassname = textBox1.Text;
txtinst = cmbInstructor.Text;
txtdesc = textBox3.Text;
txtFull = grpclassname + "\n" + txtinst + "\n" + txtdesc;
dgv1.Rows[rowcount].Cells[0].Value =
tp1.Value.ToShortTimeString() + " - " + tp2.Value.ToShortTimeString();
dgv1.Rows[rowcount].Cells[2].Value = txtFull;
//rowcount++;
}
else if (comboBox1.Text == "Wednesday")
{
DataGridViewRow row = dgv1.Rows[rowcount];
row.Height = 60;
grpclassname = textBox1.Text;
txtinst = cmbInstructor.Text;
txtdesc = textBox3.Text;
txtFull = grpclassname + "\n" + txtinst + "\n" + txtdesc;
dgv1.Rows[rowcount].Cells[0].Value =
tp1.Value.ToShortTimeString() + " - " + tp2.Value.ToShortTimeString();
dgv1.Rows[rowcount].Cells[3].Value = txtFull;
//rowcount++;
}