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 4623976
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:03:53+00:00 2026-05-22T03:03:53+00:00

Possible Duplicate: How do you pass an object from form1 to form2 and back

  • 0

Possible Duplicate:
How do you pass an object from form1 to form2 and back to form1?

I’m used to passing variables between windows forms by simply passing them as a parameter.
Now I have a form that is already open (let’s call it FormMain), and another form that should act like a dialog (FormTask). The user cannot interact with the main form until he has filled in the information on FormTask. FormTask simply contains a single textbox, and the value of this textbox should be returned to FormMain, and kept track of as a variable. FormTask requires a parameter exerciseType. When FormTask opens it checks the value of this parameter and sets the default value of the textbox accordingly. This already works, I’m just kind of clueless on how to return my string value to the already open MainForm.
These dialogs only seem to be able to return DialogResults, which isn’t what I’m after. I’m not too experienced either, and I’d rather avoid fumbling around to make my own custom dialog.

FormMain:

FormTask formTask = new FormTask(exerciseType);
formOpgaveInvoker.ShowDialog();

FormTask:

private void button1_Click(object sender, EventArgs e)
{
    string opgave = textBoxOpgave.Text;
    // return string value to MainForm here
}
  • 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-22T03:03:54+00:00Added an answer on May 22, 2026 at 3:03 am

    Create public property in FormTask

    public string Opgave { get {return textBoxOpgave.Text;}}
    

    And check it after ShowDialog();

    FormTask formTask = new FormTask(exerciseType);
    formOpgaveInvoer.ShowDialog();
    formOpgaveInvoer.Opgave;  // here it is
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Passing data between asp.net pages how to pass value of TEXTBOX from
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
Possible Duplicates: Why use ref keyword when passing an Object? When to pass ref
Possible Duplicate: Passing an IDisposable object by reference causes an error? Why doesn't C#
Possible Duplicate: How to pass a value from one Activity to another in Android?
Possible Duplicate: Pass a PHP string to a Javascript variable (and escape newlines) I
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: SWIG Java Retaining Class information of the objects bouncing from C++ Question
Possible Duplicate: Is Java pass-by-reference? I found an unusual Java method today: private void
Possible Duplicate: Is it possible to pass parameters by reference using call_user_func_array()? I have

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.