private void dgvListBook_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } DataGridViewRow row = dgvListBook.Rows[e.RowIndex]; txtID.Text = row.Cells[0].Value.ToString(); txtName.Text = row.Cells[1].Value.ToString(); txtDate.Text = row.Cells[2].Value.ToString(); String name = authordao.searchAuthorName(row.Cells[3].Value.ToString()); cbAuthor.SelectedIndex = cbAuthor.Items.IndexOf(name); String category = categorydao.searchCategoryName(row.Cells[4].Value.ToString()); cbCategory.SelectedIndex = cbCategory.Items.IndexOf(category); String pub = publisherdao.searchPublisherName(row.Cells[5].Value.ToString()); cbPub.SelectedIndex = cbPub.Items.IndexOf(pub); txtQuan.Text = row.Cells[6].Value.ToString(); }