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

  • Home
  • SEARCH
  • 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 7697119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:56:13+00:00 2026-05-31T21:56:13+00:00

Possible Duplicate: How to Pass String to another forms from one form in c#

  • 0

Possible Duplicate:
How to Pass String to another forms from one form in c#

C# Query : When I login to my software I select the desired username using combobox. After I login, I want to see the username text in the main window on the toolstrip.

I tried get and set method but something is going wrong. Can you please help me out? Thanks in advance.

Form 1:

public partial class login : Form
{
    public login()
    {
        InitializeComponent();
    }

    public string username
    {
        get{
            return a.ToString();}
    }

    public string a;

    private void button1_Click(object sender, EventArgs e)
    {
        a = comboBox1.Text;
        Form main1 = new main();
        main1.Show();
     // rest is the code for login.
    }
}

Form 2:

public partial class main : Form
{
    public main()
    {
        InitializeComponent();
    }
    public string username
    {
        set { toolStripLabel1.Text = value; }
    }
    private void main_Load(object sender, EventArgs e)
    {
        Form home = new home();
        home.MdiParent = this;
        home.WindowState = FormWindowState.Maximized;
        home.Show();
    }
}

Here Home is form3 a childform which opens in Main form. at load event of Main form itself.

  • 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-31T21:56:14+00:00Added an answer on May 31, 2026 at 9:56 pm

    Replace the main_Load code with this:

    private void main_Load(object sender, EventArgs e)
    {
        login home = new login();
        home.MdiParent = this;
        home.WindowState = FormWindowState.Maximized;
        home.ShowDialog(); // waits for the home form to be closed
    
        this.username = home.username;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to pass a value from one Activity to another in Android?
Possible Duplicate: C++ deprecated conversion from string constant to 'char*' I want to pass
Possible Duplicate: Pass a PHP string to a Javascript variable (and escape newlines) I
Possible Duplicate: Parse query string into an array What's the fastest method , to
Possible Duplicate: Pass a PHP string to a Javascript variable (and escape newlines) I'm
Possible Duplicate: Pass a PHP string to a Javascript variable (including escaping newlines) So
Possible Duplicate: How to pass a variable / data from javascript to php and
Possible Duplicate: Is there ever a good reason to pass a string to setTimeout?
Possible Duplicate: How do you pass an object from form1 to form2 and back
Possible Duplicate: Passing data between asp.net pages how to pass value of TEXTBOX from

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.