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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:58:14+00:00 2026-06-15T23:58:14+00:00

My TextBox and Label Text property does not update when I call a method

  • 0

My TextBox and Label Text property does not update when I call a method from another Form?

Here is the code

//Form1 Codes
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
    Form2 frm= new Form2 ();
    frm.UpdateText(this.treeView1.SelectedNode.Text.ToString());
    this.Close();
}

//Form2 codes
//show Form1
private void Button1_Click(object sender, EventArgs e)
{
    Form1 Frm = new Form1();
    Frm.ShowDialog();
}

//update Textbox and lable
public void UpdateText(string text)
{
    this.label1.Text = text;
    textBox1.Text = text;
    label1.Refresh();
}

Thanks 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-15T23:58:14+00:00Added an answer on June 15, 2026 at 11:58 pm

    You are creating new instance of Form2 (which in not visible to client, because you don’t show it) and updating it’s label. What you need is updating label on existing instance of Form2. So, you need to pass instance of Form2 to Form1, which you create in Button1_Click event handler. Or (the better way) you need to define property on Form1 and read that property when Form1 is closed:

    Form1 code

    public string SelectedValue 
    { 
         get { return treeView1.SelectedNode.Text; }
    }    
    
    void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
    {
         // this means that user clicked on tree view
         DialogResult = DialogResult.OK;
         Close();
    }
    

    Form2 code

    private void Button1_Click(object sender, EventArgs e)
    {
        using(Form1 frm1 = new Form1())
        {
           if(frm1.ShowDialog() != DialogResult.OK)
              return;
    
           UpdateText(frm1.SelectedValue);
        }
    }
    
    public void UpdateText(string text)
    {
        label1.Text = text;
        textBox1.Text = text;
        label1.Refresh();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I update a textbox or label (specfically an asp.net control) text property
My code Asp block: ---------- <ContentTemplate> <asp:Label runat=server ID=lblHelloWorld Text=label /> <br /> <asp:TextBox
I have few controls (Label, Custom Textbox, Datagridview) docked on a form. When I
The Label, Button, TextArea, and TextBox (abbreviated LBTT from now on) are capable of
I created a form with a label, textbox and a button. In the form
I need to bind the text property of a textbox that it is located
I have a label on a page and I'm updating the text property of
Is SearchString acting as property of Page class? Here is code, <%@ Page Language=C#
There is (suppose to be) a label or textbox in hidden mode that from
I'm showing a modal form with 2 textboxes; first textbox is passed from the

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.