public void LayDuLieuLenComboBox(ComboBox com) { DayData day = new DayData(); com.DataSource = day.LayDSDay(); com.DisplayMember = "TENDAY"; com.ValueMember = "MADAY"; }
public void LayDuLieuLenDataGridViewComboBoxColumn(DataGridViewComboBoxColumn col) { DayData day = new DayData(); col.DataSource = day.LayDSDay(); col.DisplayMember = "TENDAY"; col.ValueMember = "MADAY"; col.DataPropertyName = "MADAY"; col.HeaderText = "Dãy"; }
/// <summary> /// Hiển Thị Dữ liệu lên Form /// </summary> /// <param name="da"></param> /// <param name="bin"></param> public void HienThi(DataGridViewX da, BindingNavigator bin, TextBox ma, TextBox ten, TextBox soluong, ComboBoxEx ktx, ComboBoxEx codo) { #region Bingding BindingSource source = new BindingSource(); source.DataSource = data.LayDSDay(); da.DataSource = source; bin.BindingSource = source; #endregion da.Columns.RemoveAt(3); da.Columns.RemoveAt(3); #region Cột Ký túc xá DataGridViewComboBoxColumn comKTX = new DataGridViewComboBoxColumn(); comKTX.HeaderText = "Ký túc xá"; comKTX.Name = "CotKTX"; new KTXCtrl().LayDataGridViewComboBoxColumnTuDSKTX(comKTX); da.Columns.Add(comKTX); #endregion #region Cột Cờ đỏ DataGridViewComboBoxColumn comCoDo = new DataGridViewComboBoxColumn(); comCoDo.HeaderText = "Cờ đỏ"; comCoDo.Name = "CotCoDo"; new SinhVienCtrl().LayDataGridViewComboBoxColumn_CoDo(comCoDo); da.Columns.Add(comCoDo); #endregion if (ktx.DataBindings.Count > 0)//Kiểm tra xem các control dá được Binding chưa { ktx.DataBindings.RemoveAt(0); codo.DataBindings.RemoveAt(0); ma.DataBindings.RemoveAt(0); ten.DataBindings.RemoveAt(0); soluong.DataBindings.RemoveAt(0); } new KTXCtrl().LayDSKTXLenComboBox(ktx); ktx.DataBindings.Add("SelectedValue", source, "KTX"); new SinhVienCtrl().LayDSSinhVienLenComboBox(codo); codo.DataBindings.Add("SelectedValue", source, "MACODO"); ma.DataBindings.Add("Text", source, "MADAY"); ten.DataBindings.Add("Text", source, "TENDAY"); soluong.DataBindings.Add("Text", source, "SOLUONGPHG"); }
public void LayDuLieuLenComboBoxItem(ComboBoxItem cmb) { DayData hd = new DayData(); DataTable table = hd.LayDSDay(); foreach (DataRow row in table.Rows) { cmb.Items.Add(row["TenDay"]); } //cmb.DisplayMember = "TENPHG"; //cmb.ValueMember = "MAPHG"; }
public void HienThi(DataGridView dgv) { dgv.DataSource = day.LayDSDay().Tables[0]; }