2011-10-05 44 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; 
     } 
    } 
} 
相關問題