public void HienThi(DataGridView dg, BindingNavigator bn, TextBox ma, TextBox ten, ComboBox nam) { BindingSource bs = new BindingSource(); bs.DataSource = Data.LayDSHocKi(); bn.BindingSource = bs; dg.DataSource = bs; if (ma.DataBindings.Count > 0) { ma.DataBindings.RemoveAt(0); ten.DataBindings.RemoveAt(0); nam.DataBindings.RemoveAt(0); } NamHocCtrl ctrlnam = new NamHocCtrl(); dg.Columns.Add(ctrlnam.ColumnNamHoc()); dg.Columns.RemoveAt(2); ma.DataBindings.Add("Text", bs, "MAHOCKI"); ten.DataBindings.Add("Text", bs, "TENHOCKI"); NamHocData dataNam = new NamHocData(); nam.DataSource = dataNam.LayDSNamHoc(); nam.DisplayMember = "TENNAMHOC"; nam.ValueMember = "MANAMHOC"; nam.DataBindings.Add("SelectedValue", bs, "MANAM"); }
public void LayDSHocKiLenComboBox(ComboBoxEx cmb) { HocKiData hocki = new HocKiData(); cmb.DataSource = hocki.LayDSHocKi(); cmb.DisplayMember = "TENHOCKI"; cmb.ValueMember = "MAHOCKI"; }