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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:11:03+00:00 2026-05-26T04:11:03+00:00

I am trying to have a click event on a new form that gets

  • 0

I am trying to have a click event on a new form that gets the text property of controls in form1.

I have made a public method that returns the values that I need but the returned values are always null. I have looked everywhere for this.

Form1:

public List<string> returner()
{
    List<string> thevalues = new List<string>();

    thevalues.Add(textbox1.Text);
    thevalues.Add(textbox2.Text);

    return thevalues;
}

Form2:

Form1 x = new Form1();

List<string> values = x.returner();
label1.Text = values[0];
label2.Text = values[1];

My issue is that there are no values returned because Im declaring a new instance of Form1 rather than using the one that has values in it (I guess).

  • 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-26T04:11:03+00:00Added an answer on May 26, 2026 at 4:11 am

    Yes, that would explain what’s going wrong. Basically you need to tell Form2 about the relevant instance of Form1. Exactly how you do that will depend on what constructs everything. For example, you might have:

    Form1 form1 = new Form1();
    Form2 form2 = new Form2();
    form2.Form1 = form1;
    

    Or you could pass the reference in the constructor to Form2.

    If those are really the names of your forms, by the way, I’d strongly advise you to rename them to something more meaningful – something which indicates the purpose of the form. Likewise returner not only violates .NET naming conventions, it also doesn’t explain what it’s doing.

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

Sidebar

Related Questions

I have an events form that allows someone to add a new event. An
I am trying to get access to Form1’s public method on another form Form2
I am trying to have a text box resize on click. in the head:
Hi i have click event that will pop up a info window & marker
Im trying to add click events to shapes within a visio file.. I have
I'm trying to have 'help' tooltips which appear when you click on labels of
Trying to detect left click vs right click (without using jQuery!) and I have
I have other-window.xaml file and trying to open this from window.xaml on button click.
I am trying to accomplish the following: 1. On click, have a div with
I'm trying to have an AHAH-enabled form with WYSIWYG fields in Drupal 6. Problem

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.