private void thêmDanhSáchToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog op = new OpenFileDialog(); op.Filter = "xls, xlsx|*.xls;*.xlsx"; try { if (op.ShowDialog() == DialogResult.OK) { //load info be so 1 DataTable table = ExcelHelp.getDataTableExcel(op.FileName);//new DataTable(); //khoi tao tinh tong 3 bia tong3Bia = new int[table.Rows.Count]; /* * table.Columns.Add("Tên", typeof(string)); * table.Columns.Add("Lần 1", typeof(int)); * table.Columns.Add("Lần 2", typeof(int)); * table.Columns.Add("Lần 3", typeof(int)); * table.Columns.Add("Tổng", typeof(string)); * table.Rows.Add("Nguyễn Văn A", null, null, null, null); * table.Rows.Add("Nguyễn Văn b", null, null, null, null); * table.Rows.Add("Nguyễn Văn c", null, null, null, null); */ _dtgScore.DataSource = table; //mo rong phan ten _dtgScore.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; _lblName.Text = table.Rows[0][0].ToString(); //load info be so 2 DataTable table2 = ExcelHelp.getDataTableExcel(op.FileName);//new DataTable(); _dtgScore2.DataSource = table2; _dtgScore2.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; _lblName2.Text = table.Rows[0][0].ToString(); //load info be so 3 DataTable table3 = ExcelHelp.getDataTableExcel(op.FileName);//new DataTable(); _dtgScore3.DataSource = table3; _dtgScore3.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; _lblName3.Text = table.Rows[0][0].ToString(); } } catch (Exception ex) { } }