2011-10-05 68 views

回答

0

我最终什么事做了移动bringtofront功能已经被添加后面板。在面板被添加到窗口之前,我没有意识到我正在做这件事。

1

让您的左侧面板停靠,而不是将另一个对接,将其大小设置为初始客户区将其固定在顶部,底部,左侧和右侧。然后为了确保事情按照正确的顺序进行,请右键单击左侧面板并选择前移到前。

这里的设计师代码:

 // 
     // 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; 
     } 
    } 
} 
相关问题