如何使一个停靠面板去另一个停靠面板的顶部



我有一个面板停靠在左边,另一个面板停靠在中间作为填充。我左边的面板开始宽度为8,然后它滑开到295。我需要它越过面板。它会把整个面板都推倒吗?有什么办法能让它越过面板吗?

让左侧面板停靠,而不是停靠另一个,将其大小与初始客户端区域固定在顶部,底部,左侧和右侧。然后,为了确保事情按照正确的顺序发生,右键单击左侧面板并选择"带到前面"。

下面是设计代码:

        // 
        // panelLeft
        // 
        this.panelLeft.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
        this.panelLeft.Dock = System.Windows.Forms.DockStyle.Left;
        this.panelLeft.Location = new System.Drawing.Point(0, 0);
        this.panelLeft.Name = "panelLeft";
        this.panelLeft.Size = new System.Drawing.Size(54, 456);
        this.panelLeft.TabIndex = 0;
        this.panelLeft.Click += new System.EventHandler(this.PanelLeftClick);
        // 
        // panelOther
        // 
        this.panelOther.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
        | System.Windows.Forms.AnchorStyles.Left) 
        | System.Windows.Forms.AnchorStyles.Right)));
        this.panelOther.BackColor = System.Drawing.Color.Maroon;
        this.panelOther.Location = new System.Drawing.Point(60, 0);
        this.panelOther.Name = "panelOther";
        this.panelOther.Size = new System.Drawing.Size(477, 456);
        this.panelOther.TabIndex = 1;

和显示管理的表单处理程序代码。(点击左边面板可以放大或缩小…)

using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1() {InitializeComponent();}
        private bool _isLeftPanelBig;
        private void PanelLeftClick(object sender, EventArgs e)
        {
            panelLeft.Size = _isLeftPanelBig ? new Size(80, 300) : new Size(500, 300);
            _isLeftPanelBig = !_isLeftPanelBig;
        }
    }
}

我最终做的是在添加面板后移动bringtofront函数。在把面板加到窗户上之前,我没有意识到我这样做了。

相关内容

  • 没有找到相关文章