| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 659 人关注过本帖
标题:C# 怎样实现自动布局
只看楼主 加入收藏
litao31415
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-8-30
结帖率:100%
收藏
已结贴  问题点数:2 回复次数:3 
C# 怎样实现自动布局
描述:怎样实现通过按下一个按钮来删除某一个控件时,其他的控件会自动伸展以补齐空位,当下次需要显示该控件时其他控件就缩小,以腾出空间放下该控件?有什么思路?
搜索更多相关主题的帖子: 空间 
2014-10-31 10:53
xydddaxia
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:33
帖 子:466
专家分:2307
注 册:2009-3-20
收藏
得分:2 
TableLayoutPanel控件

站在春哥的肩膀上
2014-10-31 11:02
litao31415
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2011-8-30
收藏
得分:0 
回复 2 楼 xydddaxia
用鼠标拖动控件(譬如richtexbox)边缘,伸缩是需要自己添加事件处理吗?譬如重新计算里面的控件位置和尺寸?
2014-11-03 09:49
xydddaxia
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:33
帖 子:466
专家分:2307
注 册:2009-3-20
收藏
得分:0 
通过一些鼠标事件可以解决调整大小
程序代码:
  private bool isMouseDown = false;
        private int mouseX = 0;
        private int baseWidth = 0;
        private void listBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown)
            {
                this.listBox1.Width = baseWidth + e.X - mouseX;
                if (this.listBox1.BorderStyle != BorderStyle.FixedSingle)
                {
                    this.listBox1.BorderStyle = BorderStyle.FixedSingle;
                }
            }
            else
            {
                int n = Math.Abs(e.X - this.listBox1.Width);
                this.label1.Text = n.ToString();
                if (n < 10)
                {
                    if (this.Cursor != Cursors.SizeWE)
                    {
                        this.listBox1.Cursor = this.Cursor = Cursors.SizeWE;

                    }
                }
                else
                {
                    if (this.Cursor != Cursors.Default)
                        this.listBox1.Cursor = this.Cursor = Cursors.Default;
                }
            }
        }
        private void listBox1_MouseUp(object sender, MouseEventArgs e)
        {
            isMouseDown = false;
            if (this.listBox1.BorderStyle != BorderStyle.Fixed3D)
            {
                this.listBox1.BorderStyle = BorderStyle.Fixed3D;
            }
        }

        private void listBox1_MouseDown(object sender, MouseEventArgs e)
        {
            isMouseDown = true;
            baseWidth = this.listBox1.Width;
            mouseX = e.X;
        }

        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            listBox1_MouseMove(sender, e);
        }

站在春哥的肩膀上
2014-11-04 09:59
快速回复:C# 怎样实现自动布局
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017287 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved