首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c# 构造函数疑问,该如何处理

2012-03-27 
c# 构造函数疑问请教各位大侠,构造函数怎么把控件获取控件我这里有个Timer类,类中有个构造函数,有个定时器

c# 构造函数疑问
请教各位大侠,构造函数怎么把控件获取控件
我这里有个Timer类,类中有个构造函数,有个定时器,我想实现每隔1妙, picPlayer.Load(path);就重新加载1张图片
下面是类中的代码

C# code
 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;               }    }

这个是Form中的代码
C# code
 time.StartTime();BLL.ShowPicture sp = new BLL.ShowPicture(picPlayer);


[解决办法]
timer_Tick是form的成员函数,它可以直接使用form的PictureBox

[解决办法]
ref

热点排行