private void simpleButton3_Click(object sender, EventArgs e) { frmSubstationCodeSel f = new frmSubstationCodeSel(); if (f.ShowDialog() == DialogResult.OK) { code = f.FocusedObject.UID; this.Close(); } else { this.DialogResult = DialogResult.None; } //this.Close(); }