日期:2014-05-17  浏览次数:20906 次

c# 按钮移动 急救!!!!!
最近刚学完c#,老师要求我们开始做项目了,经我们小组(3人)讨论,决定做一个和仓库管理差不多的系统,但是问题来,如图:假如点击第二个按钮,它就会往上走,且速度像是被拉上去一般,很是好看,它上去之后,就会有一些新的按钮出来,然后又点击第三个按钮,也是和第二个按钮一样,下面的按钮也是这样,不知道这样的效果是怎么做出来的,想请大家帮忙指点指点,还没去问老师,小弟感激不尽,这是我们第一个项目啊!!!感觉太繁琐了.........最好能有代码外加注释了(我在别的板块也发了这个帖子,可是没啥人回....真的挺急的)
c# 按钮移动

------解决方案--------------------
//悄悄的抛出一块砖头

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace TestWin
{
    public partial class Form1 : Form
    {
        private Thread threadForm = null;
        public Form1()
        {
            InitializeComponent();
            threadForm = Thread.CurrentThread;
            Button tButton = new Button()
            {
                 Text="测试按钮!"
            };
            SetNewPostion(tButton, new Point(0,0));
            tButton.Click+=new EventHandler(tButton_Click);
            Controls.Add(tButton);
        }
        private void SetNewPostion(Control ct, Point positon)
        {
            ct.Location = positon;
        }
        private delegate void MoveDelegate(object o);
        private bool IsMoving = false;
        private IAsyncResult result = null;
        protected void tButton_Click(object o, EventArgs e)
        {
            if (IsMoving)
            {
                this.EndInvoke(result);
            }
            else
            {