private void dataGridView1_SelectionChanged(object sender, EventArgs e) { if (!dataGridView1.Focused) { dataGridView1.ClearSelection(); tabNoHeader1.Visible = false; return; } if (tabNoHeader1.Visible && tabNoHeader1.SelectedIndex == 1) { return; } foreach (Control c in tabThem.Controls) { errorProvider1.SetError(c, string.Empty); } tabNoHeader1.SelectedIndex = 0; tabNoHeader1.Visible = true; btnThem.Text = @"Sửa"; using (HangHoaBUS bus = new HangHoaBUS()) { string tennhanghoa = dataGridView1.CurrentRow?.Cells[0].Value.ToString(); HangHoaDTO info = bus.LoadHangHoa(tennhanghoa); txtTenHangHoa.Text = info.TenHangHoa; txtGiaBan.Text = info.GiaBan.ToString(); txtDonViTinh.Text = info.DonViTinh; txtSoLuongTon.Text = info.SoLuongTon.ToString(); txtGhiChu.Text = info.GhiChu; } }