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

timer1_Tick(.)怎么调用Mybutton_Paint(.)事件呢

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

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

热点排行