public OpenedCourses openedCourses() { string courseName, status, prerq; List <string> lt = new List <string>(); string sn = "SELECT Course_Name,Pre_Requirement_1 FROM Curriculum"; SqlCeCommand cmd = new SqlCeCommand(sn, con); SqlCeDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { courseName = rdr["Course_Name"].ToString().Trim(); prerq = rdr["Pre_Requirement_1"].ToString().Trim(); string pn = "SELECT Status FROM Grade_By_Semester WHERE Course_Name='" + prerq + "'"; SqlCeCommand pmd = new SqlCeCommand(pn, con); SqlCeDataReader pdr = pmd.ExecuteReader(); while (pdr.Read()) { //ListView.Checkboxes = true; status = pdr["Status"].ToString().Trim(); if (status == "YES") { lt.Add(courseName); } } } OpenedCourses opc = new OpenedCourses(lt); con.Close(); return(opc); }
public void dynamicCheckBox() { DatabaseAccess db = new DatabaseAccess(); OpenedCourses opc = db.openedCourses(); CheckBox chk; List <string> lt = opc.getCourses(); int p = lt.Count; //MessageBox.Show(p.ToString()); for (int i = 0; i < p; i++) { chk = new CheckBox(); chk.Name = "checkBox" + Convert.ToString(i); chk.Text = lt[i]; chk.AutoSize = true; chk.Location = new Point(30, i * 20); checkedListBox1.Controls.Add(chk); } }