如何使停靠面板超越另一个停靠面板

时间:2011-10-05 15:35:25

标签: c# windows-forms-designer docking panels

我有一个停靠在左侧的面板和另一个停靠在中间的面板。我左边的面板开始宽度为8,然后滑开到295.我需要它超过面板的顶部。它正在做的是推动整个面板?有没有办法让它超越专家组?

2 个答案:

答案 0 :(得分:1)

让左侧面板停靠,而不是对接另一个,将其调整到初始客户区域,将其固定在顶部,底部,左侧和右侧。然后为了确保按正确的顺序发生事情,右键单击左侧面板并选择Bring To Front。

以下是设计师代码:

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

答案 1 :(得分:0)

我最终做的是在添加面板后移动了前置功能。面板被添加到窗口之前,我没有意识到我正在做这件事。