private void button2_Click(object sender, EventArgs e) { try { foreach (Form form in Application.OpenForms) { if (form.GetType() == typeof(UpdateUserForm)) { form.Activate(); return; } } UpdateUserForm update = new UpdateUserForm(role); update.SelectID = SelectItemRow; update.SelectRoleId = SelectRoleId; update.textBox2.Text = gridView1.GetFocusedDataRow()[2].ToString(); update.textBox3.Text = gridView1.GetFocusedDataRow()[3].ToString(); update.textBox4.Text = gridView1.GetFocusedDataRow()[4].ToString(); update.comboBox1.Text = gridView1.GetFocusedDataRow()[5].ToString(); update.ShowDialog(); } catch (Exception ex) { MessageBox.Show("Для редактирования записи, необходимо указать строку! " + ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void button2_Click(object sender, EventArgs e) { try { if (SelectItemRow != 0) { foreach (Form form in Application.OpenForms) { if (form.GetType() == typeof(UpdateUserForm)) { form.Activate(); return; } } UpdateUserForm update = new UpdateUserForm(role); update.SelectID = SelectItemRow; update.SelectRoleId = SelectRoleId; update.Owner = this; update.ShowDialog(); } else { MessageBox.Show("Для редактирования записи, необходимо указать строку! ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }