我每次尝试尝试从外部Timer类刷新datagridview时,都会出错:不允许使用线程综合]
Form1.cs: public void Main_Window_Load(object sender, EventArgs e) { SetDatagridView(); } public void SetDatagridView() { DataTable MBServices = new DataTable(); DataView MBServicesVW = new DataView(); MBServices = getMasterServicetblOverview("8"); MBServices.Columns.Add("State", typeof(Image)); MBServices.Columns.Remove("state"); MBServicesVW = new DataView(MBServices); dataGridSHToverview.DataSource = MBServicesVW; } Timer.cs: class Timer { public class NamedTimer : System.Timers.Timer { } public static void TimerDo() { Timer timer = new Timer(); timer.Interval = (60000); timer.Elapsed += Main_Tick; timer.AutoReset = false; timer.Start(); } public static void Main_Tick(object sender, EventArgs args) { //there a want to call SetDatagridView() } }
timerDo()将在主类中调用。
感谢您的帮助
我每次尝试尝试从外部Timer类刷新datagridview时都会出错:不允许使用线程综合Form1.cs:public void Main_Window_Load(object sender,EventArgs ...