c# 构造函数疑问
请教各位大侠,构造函数怎么把控件获取控件
我这里有个Timer类,类中有个构造函数,有个定时器,我想实现每隔1妙, picPlayer.Load(path);就重新加载1张图片
下面是类中的代码
private int count = 1; private int num=0; public void StartTime() { if (num==0) { xmlServer.GetXmlInfo(); num++; } timer.Tick += new EventHandler(timer_Tick); timer.Interval = 1000; timer.Start(); } void timer_Tick(object sender, EventArgs e) { string path = xmlServer.IsInfo.DicImage1[count]; //我想知道,这里怎么写,才能让picPlayer得到form中的PictureBox picPlayer.Load(path); count++; } /// <summary> /// 定义1个构造函数来 /// 对picture进行传值 /// </summary> public class ShowPicture { private PictureBox pb; public ShowPicture() {} public ShowPicture(PictureBox picPlayer) { this.pb = picPlayer; } }
time.StartTime();BLL.ShowPicture sp = new BLL.ShowPicture(picPlayer);