private void menuUpdate_Click(object sender, EventArgs e) { try { if (this.dgvUser.SelectedRows.Count > 0) { int index = this.dgvUser.SelectedRows[0].Index; int count = this.dgvUser.Rows.Count; FormAddUser form = new FormAddUser(false, this.dgvUser.SelectedRows[0]); if (form.ShowDialog() == DialogResult.OK) { this.btnSelect_Click(null, null); if (this.dgvUser.Rows.Count == count) { this.dgvUser.Rows[index].Selected = true; } } } } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }
private void btnAdd_Click(object sender, EventArgs e) { FormAddUser form = new FormAddUser(true, null); if (form.ShowDialog() == DialogResult.OK) { this.btnSelect_Click(null, null); this.dgvUser.Rows[this.dgvUser.Rows.Count - 1].Selected = true; } }