private void sub_form_1_Btn_Cancel_Click(object sender, EventArgs e) { myform sub_form = (myform)((TableLayoutPanel)(sender as Button).Parent).Parent; sub_form.DialogResult = DialogResult.Cancel; sub_form.Close(); }
private void Sub_Form_1_KeyDown(object sender, KeyEventArgs e) { TableLayoutPanel temp = (TableLayoutPanel)(sender as TextBox).Parent; myform sub_form = (myform)temp.Parent; if (e.KeyCode == Keys.Enter) { sub_form.Return_Value1 = temp.Controls[2].Text; sub_form.DialogResult = DialogResult.OK; sub_form.Close(); } else if (e.KeyCode == Keys.Escape) { sub_form.DialogResult = DialogResult.Cancel; sub_form.Close(); } }
private void sub_form_1_Btn_Ok_Click(object sender, EventArgs e) { TableLayoutPanel temp = (TableLayoutPanel)(sender as Button).Parent; myform sub_form = (myform)temp.Parent; sub_form.Return_Value1 = temp.Controls[2].Text.Trim(); sub_form.DialogResult = DialogResult.OK; sub_form.Close(); }