Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4038812
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:31:09+00:00 2026-05-20T12:31:09+00:00

I have a main form (let’s call it frmHireQuote) that is a child of

  • 0

I have a main form (let’s call it frmHireQuote) that is a child of a main MDI form (frmMainMDI), that shows another form (frmImportContact) via ShowDialog() when a button is clicked.

When the user clicks the ‘OK’ on frmImportContact, I want to pass a few string variables back to some text boxes on frmHireQuote.

Note that there could be multiple instances of frmHireQuote, it’s obviously important that I get back to the instance that called this instance of frmImportContact.

What’s the best method of doing this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:31:10+00:00Added an answer on May 20, 2026 at 12:31 pm

    Create some public Properties on your sub-form like so

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

    then set this inside your sub-form ok button click handler

    private void btnOk_Click(object sender,EventArgs e)
    {
        this.ReturnValue1 = "Something";
        this.ReturnValue2 = DateTime.Now.ToString(); //example
        this.DialogResult = DialogResult.OK;
        this.Close();
    }
    

    Then in your frmHireQuote form, when you open the sub-form

    using (var form = new frmImportContact())
    {
        var result = form.ShowDialog();
        if (result == DialogResult.OK)
        {
            string val = form.ReturnValue1;            //values preserved after close
            string dateString = form.ReturnValue2;
            //Do something here with these values
    
            //for example
            this.txtSomething.Text = val;
        }
    }
    

    Additionaly if you wish to cancel out of the sub-form you can just add a button to the form and set its DialogResult to Cancel and you can also set the CancelButton property of the form to said button – this will enable the escape key to cancel out of the form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a main form that can open MDI children inside it.
I have a main form, and a floating child form that is non-modal. The
I have two forms, let's call them Main and Form2 . Main form consists
I have a Main form.I want to launch another form from it and launch
i have a main form that contains an inner form (that inner form appears
I have a main wpf form that opens a new form. However when that
I have one main form, and i want to dynamically change it's content, via
Let's say that I have a file (file1.php) with a simple form with the
I have an Access Form whose source data is 2 tables, let's call them
I have an app, let us call it 'com.company.foo', with a main Activity 'FooBar'.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.