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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:26:55+00:00 2026-06-10T09:26:55+00:00

I need help passing input in Form2.textbox1 to Form1.sti Form1 = Main working window

  • 0

I need help passing input in Form2.textbox1 to Form1.sti
Form1 = Main working window
Form2 = Popup window, to enter path.

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

    private void Form2_Load(object sender, EventArgs e)
    {

    }

    public string sti { get; set; }

    private void button1_Click(object sender, EventArgs e)
    {
        textBox1.Text = sti;
        this.Close();
    }
}

public partial class Form1 : Form
{
    int CountR = 1;

    public Form1()
    {
        InitializeComponent();
    }

    public string sti { get; set; }

    public void Form1_Load(object sender, EventArgs e)
    {
        Form2 popup = new Form2();
        popup.ShowDialog();
        popup.Dispose();
    }
   public void button1_Click(object sender, EventArgs e)
    {                
    Label7.Text = sti; 
     }

But it always returns Null.

I’ve builded it this way because I don’t want user to mess with the path only IT administrators.

Thank you in advance

  • 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-06-10T09:26:57+00:00Added an answer on June 10, 2026 at 9:26 am

    You are creating a new Form1 that does not have a reference to the Form2 that you created.

    You changed your example, you have created 2 different sti properties, you need to assign the Form2 sti value to the property in Form1 before you close Form2.

    This code should work for you.

    Form1

    public partial class Form1 : Form
    {
        public string sti { get; set; } 
    
        public Form1()
        {
            InitializeComponent();
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            Form2 popup = new Form2();
            popup.ShowDialog();
            sti  = popup.sti;
            popup.Close();
            popup.Dispose(); 
    
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = sti;
        }
    
    }
    

    Form2

    public partial class Form2 : Form
    {
        public string sti { get; set; } 
    
        public Form2()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
    
            sti = textBox1.Text;
            this.Hide();
        }
    }
    

    You can also create a static class that can be referenced from both forms, that way you are dealing with only one sti property. Something like this:

    Form1

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            myProperties.sti = "Hello";
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            Form2 popup = new Form2();
            popup.ShowDialog();
            popup.Dispose(); 
    
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = myProperties.sti;
        }
    }
    
    public static class myProperties
    {
        public static string sti { get; set; } 
    }
    

    Form2

    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            textBox1.Text = myProperties.sti;
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
    
            myProperties.sti  = textBox1.Text;
            this.Close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started working on a c project. Need help with passing function pointers/macro functions/etc.
Need help getting Ember-Data working with Zend Rest. At first, I'm familiar with Zend
I need help with malloc() inside another function . I'm passing a pointer and
I need some help passing arguments to a jquery function. I have an html
i need help in passing prefix to a system procedure.. exec [your database name]..sp_tables
In a program I'm working on, i need the user to input time ranges,
I need help in parsing big Json file: {status:{code:200,text:OK},content:[{proposalId:12536,providerId:1,supervisorName:null,supervisorEmail:lolbroek_13@hotmail.com,hostInstitution:qsd,hostCountry:qsd,hostCity:QSD,hostTypeId:1,title:qsd,status:available,numberStudents:null,description:qsd,categoryId:34,startDate:null,endDate:null,submitDate:null,expectedWorkload:null,purpose:null,workOrganisationId:1,function:null,audienceId:1,preConditions:,certificationGranted:null,deliverables:null,expenses:null,revenue:null,vacancies:null,uploadImg:http:\/\/193.136.60.238\/\/MUTW2012\/core\/img\/internship.png}, {proposalId:12537,providerId:1,supervisorName:null,supervisorEmail:lolbroek_13@hotmail.com,hostInstitution:qsd,hostCountry:qsd,hostCity:QSD,hostTypeId:1,title:qsd,status:available,numberStudents:null,description:qsd,categoryId:34,startDate:null,endDate:null,submitDate:null,expectedWorkload:null,purpose:null,workOrganisationId:1,function:null,audienceId:1,preConditions:,certificationGranted:null,deliverables:null,expenses:null,revenue:null,vacancies:null,uploadImg:http:\/\/193.136.60.238\/\/MUTW2012\/core\/img\/internship.png}, {proposalId:12538,providerId:1,supervisorName:null,supervisorEmail:lolbroek_13@hotmail.com,hostInstitution:qsd,hostCountry:qsd,hostCity:QSD,hostTypeId:1,title:qsd,status:available,numberStudents:null,description:qsd,categoryId:34,startDate:null,endDate:null,submitDate:null,expectedWorkload:null,purpose:null,workOrganisationId:1,function:null,audienceId:1,preConditions:,certificationGranted:null,deliverables:null,expenses:null,revenue:null,vacancies:null,uploadImg:http:\/\/193.136.60.238\/\/MUTW2012\/core\/img\/internship.png}, {proposalId:12539,providerId:1,supervisorName:null,supervisorEmail:lolbroek_13@hotmail.com,hostInstitution:qsd,hostCountry:qsd,hostCity:QSD,hostTypeId:1,title:qsd,status:available,numberStudents:null,description:qsd,categoryId:34,startDate:null,endDate:null,submitDate:null,expectedWorkload:null,purpose:null,workOrganisationId:1,function:null,audienceId:1,preConditions:,certificationGranted:null,deliverables:null,expenses:null,revenue:null,vacancies:null,uploadImg:http:\/\/193.136.60.238\/\/MUTW2012\/core\/img\/internship.png}, ................[etc] I
I need help in retrieving a JSON object and parsing the array into my
Need help, function getFamily() { FB.api('/me/family', function(response) { alert(JSON.stringify(response)); }); } With the above
Need help with a query that I wrote: I have three tables Company id

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.