读书人

timer1_Tick(.)怎么调用Mybutton_Pai

发布时间: 2011-12-27 22:22:55 作者: rapoo

timer1_Tick(..)如何调用Mybutton_Paint(..)事件呢?
大家请帮个忙,在 timer1_Tick()如何调用
Mybutton_Paint()事件呢?


private voidobject sender, EventArgs e)
{

if (this.imageList1!= null && this.imageList1.Images.Count > 0)
{
index = nCurrentindex % this.imageList1.Images.Count;

nCurrentindex++;
if (nCurrentindex > this.imageList1.Images.Count * 10)
{
nCurrentindex = 0;
}
this.Mybutton_Paint(sender,e);

}
}
private void Mybutton_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Image img = imageList1.Images[index];
g.DrawImage(img, 0, 0,32,32);
}


[解决办法]
this.Invalidate();

此方面会触发Paint()事件.
[解决办法]
insert the code in the timer1_Tick() method:

Mybutton_Paint(null,null);

or

Mybutton_Paint(this,null);

or

Mybutton_Paint(this,this.CreateGraphics());
[解决办法]
抱歉有个错字。
---------------------------------
this.Invalidate();

此方法会触发Paint()事件.
[解决办法]
用这个Refresh()试试

读书人网 >C#

热点推荐