Example #1
0
        private void frmThemLop_Load(object sender, EventArgs e)
        {
            try
            {
                dtDanhSachMon        = MonBUS.GetTable();
                dtgvDSMon.DataSource = dtDanhSachMon;

                DataGridViewCheckBoxColumn checkboxColumn = new DataGridViewCheckBoxColumn();
                checkboxColumn.Width = 30;
                checkboxColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                dtgvDSMon.Columns.Insert(0, checkboxColumn);

                // add checkbox header
                Rectangle rect = dtgvDSMon.GetCellDisplayRectangle(0, -1, true);
                // set checkbox header to center of header cell. +1 pixel to position correctly.
                rect.X = rect.Location.X + (rect.Width / 4);

                CheckBox checkboxHeader = new CheckBox();
                checkboxHeader.Name            = "checkboxHeader";
                checkboxHeader.Size            = new Size(18, 18);
                checkboxHeader.Location        = rect.Location;
                checkboxHeader.CheckedChanged += new EventHandler(checkboxHeader_CheckedChanged);

                dtgvDSMon.Controls.Add(checkboxHeader);

                cmbNamHoc.DataSource    = NamHocBUS.GetList();
                cmbNamHoc.DisplayMember = "TenNamHoc";
                cmbNamHoc.ValueMember   = "MaNamHoc";
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
 private void layDanhSachMon()
 {
     try
     {
         listMonHoc.DataSource    = MonBUS.GetTable(txtThongTinTimKiem.Text);
         listMonHoc.DisplayMember = "TenMon";
         listMonHoc.ValueMember   = "MaMon";
     }
     catch (System.Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #3
0
 public void refreshMonData()
 {
     dtDanhSachMon        = MonBUS.GetTable();
     dtgvDSMon.DataSource = dtDanhSachMon;
     ((CheckBox)dtgvDSMon.Controls.Find("checkboxHeader", true)[0]).Checked = false;
 }