L
localhost
I make a modal form completely in code. I want to capture the value
of what was clicked in the form, I want the modal form to return a
string.
How can I do that? My modal-form-creation code is below. Thanks.
public virtual string FormMakeYesNo()
{
string responseValue = "";
Form yesNoForm = new Form();
Button btnYes = new Button ();
Button btnNo = new Button ();
btnYes.Text = "Yes";
btnYes.Location = new Point (10, 10);
btnYes.Click += new
EventHandler(btnYes_Click);
btnNo.Text = "No";
btnNo.Location = new Point (btnYes.Left,
btnYes.Height + btnYes.Top + 10);
yesNoForm.Text = "My Dialog Box";
yesNoForm.HelpButton = false;
yesNoForm.FormBorderStyle =
FormBorderStyle.FixedDialog;
yesNoForm.MaximizeBox = false;
yesNoForm.MinimizeBox = false;
yesNoForm.AcceptButton = btnYes;
yesNoForm.CancelButton = btnNo;
yesNoForm.StartPosition =
FormStartPosition.CenterScreen;
yesNoForm.Controls.Add(btnYes);
yesNoForm.Controls.Add(btnNo);
yesNoForm.ShowDialog();
return responseValue;
}
of what was clicked in the form, I want the modal form to return a
string.
How can I do that? My modal-form-creation code is below. Thanks.
public virtual string FormMakeYesNo()
{
string responseValue = "";
Form yesNoForm = new Form();
Button btnYes = new Button ();
Button btnNo = new Button ();
btnYes.Text = "Yes";
btnYes.Location = new Point (10, 10);
btnYes.Click += new
EventHandler(btnYes_Click);
btnNo.Text = "No";
btnNo.Location = new Point (btnYes.Left,
btnYes.Height + btnYes.Top + 10);
yesNoForm.Text = "My Dialog Box";
yesNoForm.HelpButton = false;
yesNoForm.FormBorderStyle =
FormBorderStyle.FixedDialog;
yesNoForm.MaximizeBox = false;
yesNoForm.MinimizeBox = false;
yesNoForm.AcceptButton = btnYes;
yesNoForm.CancelButton = btnNo;
yesNoForm.StartPosition =
FormStartPosition.CenterScreen;
yesNoForm.Controls.Add(btnYes);
yesNoForm.Controls.Add(btnNo);
yesNoForm.ShowDialog();
return responseValue;
}