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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:19:04+00:00 2026-05-24T12:19:04+00:00

I have a windows form ‘MyForm’ with a text box that is bound to

  • 0

I have a windows form ‘MyForm’ with a text box that is bound to a property in another class ‘MyData’. The Data source update mode is set to “On Property Change”

I used the VisualStudio IDE. It created the following code for the binding

this.txtYield.DataBindings.Add(new Binding("Text", this.BindingSourceMyDataClass, "PropertyInMyDataClass", true, DataSourceUpdateMode.OnPropertyChanged));

In the form constructor, after initialize values code was added to bind the MyData Class to the form

myDataClassInstantiated = new MyDataClass();
BindingSourceMyDataClass.DataSource = myDataClassInstantiated;

The INotifyProperty Interface has been implemented:

public double PropertyInMyDataClass
{
    get { return _PropertyInMyDataClass; }
    set
    {
        if (!Equals(_PropertyInMyDataClass, value))
        {
            _PropertyInMyDataClass = value;
            FirePropertyChanged("PropertyInMyDataClass");
        }
    }
}

A background worker is used to run the calculations and update the property ‘PropertyInMyDataClass’

I expected that the text box on the form would update automatically when the background worker completed. That didn’t happen

If I manually copy assign the value from the property to the form text box, the value is displayed properly

this.txtYield.Text = String.Format("{0:F0}", myDataClassInstantiated.PropertyInMyDataClass);

I tried to add Refresh() and Update() to the MyForm.MyBackgroundWorker_RunWorkerCompleted method, but the data still is not refreshed.

If I later run a different background worker that updates different text boxes on the same form, the text box bound to PropertyInMyDataClass gets updated

I would appreciate suggestions that will help me to understand and resolve this databinding problem

  • 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-24T12:19:05+00:00Added an answer on May 24, 2026 at 12:19 pm

    The problem comes from a couple of angles. If you are running the process on a background thread, the background thread cannot directly access a control on your form (which lives in a different thread) directly, otherwise you will get an exception. You also cannot expect the UI thread to update based on states in the background thread, unless you wire it up to do so. In order to do this, you need to invoke a delegate on the main UI thread..

    Place this code (modify it to update whatever control you want with whatever value type you want) on the UI form.

     public void UpdateOutput(string text)
         {
             this.Invoke((MethodInvoker) delegate {
               lstOutput.Items.Add(text);
             });
         }
    

    Then you can call this function in your background worker thread. (assuming your background process function lives in the same form, you can call it directly), if not then you will need a reference to the UI form in the class that the background process runs in.

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

Sidebar

Related Questions

I have a windows form, and I have a class that checks a text
I have a windows form with a text box: txtMyText. txtMyText.Text is Bound to
I have a windows form application that uses a Shared class to house all
I have a windows form on the main thread and another thread that does
I have a Windows Form and a class with two simple methods that run
I have a windows form application which has a text box and 3 buttons.
I have a Windows Form that takes quite a bit of time to load
I have a windows form app written in C#. the main_form class instantiates an
I have a Windows Form application built on a data model and a Windows
I have a windows form with DataBound DataGrid on it. Bound to a list

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.