private void btnEdit_Click(object sender, EventArgs e) { if (dgvUser.SelectedRows.Count > 0) { int rowIndex = dgvUser.CurrentCell.RowIndex; uUser.user_id = Convert.ToInt32(dgvUser.Rows[rowIndex].Cells[dalUser.UserID].Value); uUser.user_name = dgvUser.Rows[rowIndex].Cells[dalUser.Username].Value.ToString(); uUser.user_password = dalUser.getPassword(uUser.user_id); uUser.user_permissions = Convert.ToInt32(dgvUser.Rows[rowIndex].Cells[dalUser.Permission].Value); frmUserEdit frm = new frmUserEdit(uUser); frm.StartPosition = FormStartPosition.CenterScreen; frm.ShowDialog();//Item Edit LoadUserList(dgvUser); dgvUser.ClearSelection(); } else { MessageBox.Show("Please select a user."); } }