• 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;
    }

    }

    编辑器加载中...

  • 相关阅读:
    Devexpress treeList
    sql rowversion
    2015年8月9日 开始 devsxpress 学习
    定时执行任务
    Dexpress 中 grid的使用
    新版 itextsharp pdf code
    jquery ui 中的插件开发
    Centos7下git服务器及gogs部署
    JAVA(TOMCAT)远程调试
    分布式文件系统笔记(慢慢补充)
  • 原文地址:https://www.cnblogs.com/frog2008/p/2354710.html
Copyright © 2020-2023  润新知