for(int i=this.Loginpanel.Location.X;i>=0;i--)用这种效果的话。只能是收缩到form的边框上。但是如果想实现收缩至隐藏整个panel,能实现吗???????

解决方案 »

  1.   

    那你在i减到0的时候设置Visible=false;
    不知道你这样收缩是干吗
      

  2.   

    选中Panel->右键属性->找到Dock选择最中间那一块,即Fill
      

  3.   

    using System.Runtime.InteropServices; 
    #region//api
            [DllImport("user32")]
            private static extern bool AnimateWindow(IntPtr whnd, int dwtime, int dwflag);
            //dwflag的取值如下
            public const Int32 AW_HOR_POSITIVE = 0x00000001;
            //从左到右显示
            public const Int32 AW_HOR_NEGATIVE = 0x00000002;
            //从右到左显示
            public const Int32 AW_VER_POSITIVE = 0x00000004;
            //从上到下显示
            public const Int32 AW_VER_NEGATIVE = 0x00000008;
            //从下到上显示
            public const Int32 AW_CENTER = 0x00000010;
            //若使用了AW_HIDE标志,则使窗口向内重叠,即收缩窗口;否则使窗口向外扩展,即展开窗口
            public const Int32 AW_HIDE = 0x00010000;
            //隐藏窗口,缺省则显示窗口
            public const Int32 AW_ACTIVATE = 0x00020000;
            //激活窗口。在使用了AW_HIDE标志后不能使用这个标志
            public const Int32 AW_SLIDE = 0x00040000;
            //使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略
            public const Int32 AW_BLEND = 0x00080000;
            //透明度从高到低
            #endregion//从左到右 参数自己根据上面的替换实现不同的现实效果
    AnimateWindow("控件或窗体名称".Handle, 1000, AW_SLIDE | AW_HIDE | AW_HOR_POSITIVE);
    "控件或窗体名称".Show
      

  4.   

    楼主的意思是不是整个panel坐标不动,把panel收缩啊
    如果是的话,只要修改panel的高度不就行了吗
    在界面上放一个panel控件(最好修改背景色看效果),放个按钮,处理事件private void button1_Click(object sender, System.EventArgs e)
    {
    for(int i = this.panel1.Height; i > 0; i--)
    {
    this.panel1.Height = i;
    System.Threading.Thread.Sleep(10);
    Application.DoEvents();
    }
    }这样就能看见动态收缩的效果了
      

  5.   

    请问8楼Application.DoEvents();会不会影响效率???我以前从没有用过这句话
      

  6.   

    这样最后就可以隐藏掉啊:
    private void button1_Click(object sender, EventArgs e)
            {
                for (int i = this.panel1.Height,j = this.panel1.Width; i >= 0 && j >= 0; i--,j--)
                {
                    this.panel1.Height = i;
                    this.panel1.Width = j;
                    System.Threading.Thread.Sleep(10);
                    Application.DoEvents();
                }
            }
      

  7.   

    dock设置为fill,还有控件SplitContainer