SamKr
11/26/2014 - 12:03 PM

Return value from a form

Return value from a form

public string ReturnValue1 { get; set; } 
public string ReturnValue2 { get; set; }

private void btnOk_Click(object sender,EventArgs e)
{
    this.ReturnValue1 = "Something";
    this.ReturnValue2 = DateTime.Now.ToString(); 
    this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
using (var form = new frmImportContact())
{
    var result = form.ShowDialog();
    if (result == DialogResult.OK)
    {
        string val = form.ReturnValue1;        
        string dateString = form.ReturnValue2;
    }
}