0

Sorry I won't be posted code on this post. Please forgive me.

So I have a tab control and on that tab control I have labels are populated with text from and XML file. On load the data shows but once I do some actions and that text file gets updated my labels won't update unless I tab out then tab back in. I want them to update after my actions are completed.

There are buttons on my User Control that allow me the run through my program and update this text file, but when I dispose those and go back to my 'main screen' my labels are not updated on the UI. I have tried to use Invalidate, refresh, update and even Application.DoEvents. Which I know is bad practice but at this point I have no idea how to make this work. Please help. Thank you.

1 Answers1

0

When you read out the text in your text file, the resulting string is not an alias for the contents of the file; it is a snapshot of what the contents were when you read out the string.

An example would be two integers:

int a = 1;
int b = a;
a = 2;

Int b would still be equal to 1, since that was what a was when a was assigned to b; b does not change with a.

I would say that this is a fairly common beginner misconception. Just because you assigned a to b doesn't necessarily mean that b will continue to equal a in the future.

256Bits
  • 378
  • 1
  • 13