private void ComboBox1_SelectedIndexChanged(object sender, System.EventArgs e) { int index = dslop.SelectedIndex; // Console.WriteLine("index" + index); Lop lop1 = (Lop)listLop[index]; tenlop.Text = lop1.TenLop; getListSV(lop1.maLop); foreach (SinhVien sinhvien in listSV) { dsSV.Items.Add(sinhvien.MASV); } // dsSV.SelectedIndex = 0; }
private void F_AddSV_Load(object sender, System.EventArgs e) { String strLenh = "DS_LOP "; Program.myreader = Program.execSqlDataReader(strLenh, Program.connsrt); while (Program.myreader.Read()) { Lop lop = new Lop(); lop.maLop = Program.myreader.GetString(0); lop.TenLop = Program.myreader.GetString(1); listLop.Add(lop); } Program.myreader.Close(); foreach (Lop lop in listLop) { dslop.Items.Add(lop.maLop); } dslop.SelectedIndex = 0; Lop lop1 = (Lop)listLop[0]; tenlop.Text = lop1.TenLop; this.dslop.SelectedIndexChanged += new System.EventHandler(ComboBox1_SelectedIndexChanged); }