how to send and return values in modal dialog form
This is how I would call the dialog box
var regStoreForm = new RegisterStoreForm(storeID,password);
if (regStoreForm.ShowDialog(this) == DialogResult.OK)
{
storeID = regStoreForm.StoreId;
password = regStoreForm.StorePassword;
};
regStoreForm.Dispose();
And this is what the Dialog box looks like
public partial class RegisterStoreForm : Form
{
public int StoreId { get; set; }
public String StorePassword { get; set; }
public RegisterStoreForm(int storeId,string password)
{
InitializeComponent();
StoreId = storeId;
StorePassword = password;
this.textBoxPassword.Text = StorePassword;
this.textBoxStoreId.Text = StoreId.ToString();
}
private void OKbutton_Click(object sender, EventArgs e)
{
StoreId = Convert.ToInt16(textBoxStoreId.Text);
StorePassword = textBoxPassword.Text;
this.DialogResult = DialogResult.OK;
this.Close();
}
}