private void CDCreateExam_Load(object sender, EventArgs e) { teacherClass = classes.getClass(UserHelper.userID); for (int i = 0; i < teacherClass.Rows.Count; i++) { cbClass.Items.Add(teacherClass.Rows[i]["class"].ToString()); } }
private void loadClass() { for (int i = flowLayoutPanel4.Controls.Count - 1; i >= 0; i--) { Control con = flowLayoutPanel4.Controls[i]; if ((con is Label) || (con is LinkLabel)) { flowLayoutPanel4.Controls.RemoveAt(i); } } DataTable dt = classes.getClass(UserHelper.userID); for (int i = 0; i < dt.Rows.Count; i++) { Label label = new Label(); label.Location = new Point(3, 0); label.Size = new Size(394, 25); label.Text = dt.Rows[i]["class"].ToString(); LinkLabel linkLabel1 = new LinkLabel(); linkLabel1.Location = new Point(474, 0); linkLabel1.Size = new Size(65, 25); linkLabel1.Name = dt.Rows[i]["class_id"].ToString(); linkLabel1.Click += new EventHandler(labelUpdate_Click); linkLabel1.Text = "编辑"; LinkLabel linkLabel2 = new LinkLabel(); linkLabel2.Location = new Point(403, 0); linkLabel2.Size = new Size(65, 25); linkLabel2.Name = dt.Rows[i]["class_id"].ToString(); linkLabel2.Click += new EventHandler(labelDel_Click); linkLabel2.Text = "删除"; flowLayoutPanel4.Controls.Add(label); flowLayoutPanel4.Controls.Add(linkLabel1); flowLayoutPanel4.Controls.Add(linkLabel2); txtClassName.Text = ""; } }