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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:02:27+00:00 2026-05-11T05:02:27+00:00

I have 2 forms in my project, form1 and form2. When I click in

  • 0

I have 2 forms in my project, form1 and form2. When I click in a button in form1 I run this code:

Form tempform = new Form2(); tempform.Show(); 

In my code for Form2 I have a label which I now need to change the text. How can I access the label?

I tried:

tempform.label1.value = 'new text' 

And that didn’t work, I even tried to access using the Controls collection but I think I messed that up. Is there any way I can access the label? OR is there any way I can pass a value to that new form and then have that form alter the label text.

Thanks

  • 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. 2026-05-11T05:02:27+00:00Added an answer on May 11, 2026 at 5:02 am

    If the label value should only be set once, when the form is created, then use a constructor for Form2 like this:

    public Form2(string labelValue) {   _labelValue = labelValue; } 

    and then call that constructor when you create the form.

    Alternatively, if the label changes over the lifetime of the form, make a public property:

    public string LabelValue {   get { return label1.Text; }   set { label1.Text = value; } } 

    Also I would recommend naming the parameters and/or properties to reflect the meaning of the value, for example ‘titleText’ instead of ‘labelValue’. That way Form2 can decide how it wants to display the information (in the title bar, a label, a textbox, etc), and Form1 doesn’t have to worry about that.

    Edit: Consume the LabelValue property like this:

    Form2 newForm = new Form2(); // Assign object to a Form2 instead of Form newForm.LabelValue = 'new text'; newForm.Show(); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code for a button click on a form: private void
I have a windows forms (.net 3.0) project that won't run on my customer's
I have a C# Windows Forms project with a Form containing 2 ListBoxes and
I have a Windows forms project and a Web Service project in my solution,
I have a VB.NET Windows Forms project that at one point paints text directly
I have a treeview control in a Windows Forms project that has checkboxes turned
I have been working on a project that has 2 interfaces - windows forms
I have an ASP.NET MVC project with a form. In the Action method that
OK, another road bump in my current project. I have never had form elements
I have two forms, form A and form B. These forms must differ in

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.