Fabio Santos

Fabio Santos

  • NA
  • 3
  • 1.3k

Two forms, labels do not update

Nov 23 2011 1:42 PM
Hi, I'm having a hard time trying to figure out this: I have a program which has two forms: mainForm and statsForm. I collect data in the main form through buttons and then I click on the statsButton and the statsForm opens. The thing is: If I click the statsButton, the statsForm opens up with updated data, but if I leave it open and continues to use the mainForm, it does not update the labels in the statsForm. It is suppose to update, refresh or whatever every 5 seconds. I've tried this:
public StatsForm()
        {          
            InitializeComponent();
            RefreshTimer.Interval = 1000 * 1; //5 seconds
            RefreshTimer.Tick += new EventHandler(RefreshTimer_Tick);
            RefreshTimer.Enabled = true;
        }


        private void RefreshTimer_Tick(object sender, EventArgs e)
        {
            this.Refresh();
        }

I tried update, Invalidate and it does not work. I checked and the variables within the statsForm update its values but it does not update update the label assigned to it. How can I make it work?



Answers (3)