用于刷新c#中图表的计时器

时间:2014-11-22 12:50:22

标签: c# charts

我创建了一个从SQL Server数据库接收数据的图表。每当我将新数据保存到数据库中时,所有报告都会更新,但在我退出应用程序并再次登录之前,图表不会更新。我决定在C#中使用Timer来每5秒自动刷新一次图表。

//this is to invoke the timer as soon as the application launches.
      public MDIParent2()
        {
            InitializeComponent();
            myTimer.Enabled = true;
            myTimer.Start();
        }
//this is my timer event
private void myTimer_Tick(object sender, EventArgs e)
        {

            this.Refresh();
            MessageBox.Show("Refreshed!");//this was added to determine if the timer is working
        }

//this lets me stop the timer

private void button1_Click(object sender, EventArgs e)
        {
            myTimer.Stop();
        }


//this lets me resume the timer       
 private void button2_Click(object sender, EventArgs e)
        {
            myTimer.Start();
        }

我收到消息“刷新!”每5秒钟,但图表仍然没有刷新。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

用[Chart Object] .refresh()

替换this.refresh()