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()试试