winform 动画

/// //做一个动画 一个方块从原来的位置慢慢往下移动
/// 用timer picturebox两个控件

public partial class Form3 : Form
{
PictureBox p;
public Form3()
{
InitializeComponent();
}

private void Form3_Load(object sender, EventArgs e)
{

this.Width = 800;
this.Height = 600;

Bitmap newBitmap = new Bitmap(50, 50, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
Graphics g = Graphics.FromImage(newBitmap);
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(0, 0, 50, 50));
//newBitmap.Save(System.IO.Path.Combine (Environment.CurrentDirectoryEnvironment.CurrentDirectory,"1.png"), ImageFormat.Png);

p = new PictureBox();
p.Image = newBitmap;
this.Controls.Add(p);

p.Top = 50;
p.Left = 10;

System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
timer1.Tick += new System.EventHandler(this.timer1_Tick);
timer1.Interval = 1000; // 设置timer时间,单位是毫秒
timer1.Enabled = true; // 启动 timer




//Button

}
private void timer1_Tick(object sender, EventArgs e)
{
p.Top = p.Top + 50;
}

}

 

编辑器加载中...

转载于:https://www.cnblogs.com/frog2008/archive/2012/02/16/2354710.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值