欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Win Form 的 Splitter 使用心得與技巧

 更新時間:2007年04月13日 00:00:00   作者:  
今天作個分析html代碼,然后再批量下載的程序,其中用到 Splitter (分割條),編譯程序后,發(fā)現分割條不起作用,拖動分割條的時候,相鄰的兩個 Panel 沒有變換大小。為這個幾乎花了一天時間,也沒找到原因。包括到其他機子上測試。
后來,再次作一個完全獨立的測試項目,發(fā)現 Splitter 的使用有個算是 bug 的問題,如果你首先放兩個 Panel ,然后再放一個 Splitter 。(注意這時候的次序)就會產生我上面出現的問題。這時候代碼中的 InitializeComponent 函數部分代碼如下:
復制代碼 代碼如下:

private void InitializeComponent() 

// 
// ... 其他代碼 
// 
this.panel1 = new System.Windows.Forms.Panel(); 
this.panel2 = new System.Windows.Forms.Panel(); 
this.splitter1 = new System.Windows.Forms.Splitter(); 
this.panel2.SuspendLayout(); 
this.SuspendLayout(); 
// 
// ... 其他代碼 
// 
//  
// panel1 
//  
this.panel1.Dock = System.Windows.Forms.DockStyle.Left; 
this.panel1.Location = new System.Drawing.Point(0, 42); 
this.panel1.Name = "panel1"; 
this.panel1.Size = new System.Drawing.Size(120, 209); 
this.panel1.TabIndex = 6; 
this.panel1.Resize += new System.EventHandler(this.panel2_Resize); 
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint); 
//  
// panel2 
//  
this.panel2.Controls.Add(this.splitter1); 
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; 
this.panel2.Location = new System.Drawing.Point(120, 42); 
this.panel2.Name = "panel2"; 
this.panel2.Size = new System.Drawing.Size(328, 209); 
this.panel2.TabIndex = 7; 
this.panel2.Resize += new System.EventHandler(this.panel2_Resize); 
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel2_Paint); 
//  
// splitter1 
//  
this.splitter1.BackColor = System.Drawing.SystemColors.Desktop; 
this.splitter1.Location = new System.Drawing.Point(0, 0); 
this.splitter1.Name = "splitter1"; 
this.splitter1.Size = new System.Drawing.Size(3, 209); 
this.splitter1.TabIndex = 0; 
this.splitter1.TabStop = false; 
//  
// Form1 
//  
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 
this.ClientSize = new System.Drawing.Size(448, 273); 
this.Controls.Add(this.panel2); 
this.Controls.Add(this.panel1); 
this.Controls.Add(this.toolBar1); 
this.Controls.Add(this.statusBar1); 
this.Name = "Form1"; 
this.Text = "站點下載工具 2003年9月21日"; 
this.panel2.ResumeLayout(false); 
this.ResumeLayout(false); 


注意:這時候的代碼中的順序。這時候,程序的執(zhí)行是有問題的。分隔條會不起作用。
但是如果你把這三個控件放入順序修改為下面的順序就沒有問題了。
1、放入一個 Panel 比如:panel1 然后設置他的 Dock 屬性為:Left; 
2、放入一個 Splitter 比如:splitter1 設置它的背景顏色為一個特殊的顏色,便于看執(zhí)行效果;
3、放入一個 Panel 比如:panel2 然后設置他的 Dock 屬性為:Fill; 
4、編譯執(zhí)行程序,這時候就沒有問題了。
這時候正確的代碼應該是:( InitializeComponent 函數部分) 
 
復制代碼 代碼如下:

private void InitializeComponent() 

// 
// ... 其他代碼 
// 
this.panel1 = new System.Windows.Forms.Panel(); 
this.panel2 = new System.Windows.Forms.Panel(); 
this.splitter1 = new System.Windows.Forms.Splitter(); 
this.panel2.SuspendLayout(); 
this.SuspendLayout(); 
// 
// ... 其他代碼 
// 
//  
// panel1 
//  
this.panel1.Dock = System.Windows.Forms.DockStyle.Left; 
this.panel1.Location = new System.Drawing.Point(0, 42); 
this.panel1.Name = "panel1"; 
this.panel1.Size = new System.Drawing.Size(200, 209); 
this.panel1.TabIndex = 6; 
//  
// panel2 
//  
this.panel2.Controls.Add(this.splitter1); 
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; 
this.panel2.Location = new System.Drawing.Point(200, 42); 
this.panel2.Name = "panel2"; 
this.panel2.Size = new System.Drawing.Size(248, 209); 
this.panel2.TabIndex = 7; 
//  
// splitter1 
//  
this.splitter1.BackColor = System.Drawing.SystemColors.Desktop; 
this.splitter1.Location = new System.Drawing.Point(0, 0); 
this.splitter1.Name = "splitter1"; 
this.splitter1.Size = new System.Drawing.Size(3, 209); 
this.splitter1.TabIndex = 0; 
this.splitter1.TabStop = false; 
//  
// Form1 
//  
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 
this.ClientSize = new System.Drawing.Size(448, 273); 
this.Controls.Add(this.panel2); 
this.Controls.Add(this.panel1); 
this.Controls.Add(this.toolBar1); 
this.Controls.Add(this.statusBar1); 
this.Menu = this.mainMenu1; 
this.Name = "Form1"; 
this.Text = "站點下載工具 2003年9月21日"; 
this.Load += new System.EventHandler(this.Form1_Load); 
this.panel2.ResumeLayout(false); 
this.ResumeLayout(false); 

相關文章

  • c# Base關鍵字的使用

    c# Base關鍵字的使用

    c# Base關鍵字的使用示例代碼,大家可以參考下用法。
    2009-07-07
  • C#中使用Cache框架快速實現Cache操作

    C#中使用Cache框架快速實現Cache操作

    這篇文章介紹了C#中使用Cache框架快速實現Cache操作的方法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-06-06
  • C#中BitConverter.ToUInt16()和BitConverter.ToString()的簡單使用

    C#中BitConverter.ToUInt16()和BitConverter.ToString()的簡單使用

    這篇文章主要介紹了C#中BitConverter.ToUInt16()和BitConverter.ToString()的簡單使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-02-02
  • C#線程 BeginInvoke和EndInvoke使用方法

    C#線程 BeginInvoke和EndInvoke使用方法

    本文開始C#線程系列講座之一,即BeginInvoke和EndInvoke的使用方法,需要的朋友可以參考下
    2013-05-05
  • C# using語法糖圖文詳解

    C# using語法糖圖文詳解

    這篇文章主要給大家介紹了關于C# using語法糖的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-01-01
  • C#遞歸算法和排列算法

    C#遞歸算法和排列算法

    這篇文章介紹了C#的遞歸算法和排列算法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-05-05
  • c# 實現位圖算法(BitMap)

    c# 實現位圖算法(BitMap)

    這篇文章主要介紹了c# 如何實現位圖算法(BitMap),文中講解非常細致,幫助大家更好的理解和學習,感興趣的朋友可以了解下
    2020-07-07
  • 一文帶你了解C#操作MySql的方法

    一文帶你了解C#操作MySql的方法

    工作中大多數情況下用的都是 MySql 但一直沒有記錄,相關操作。這篇文章以便 MySql.Data 庫進行MySql操作,使用 C# 執(zhí)行 SQL 語句,造個輪子
    2023-03-03
  • c#不使用windows api函數打開我的電腦和獲取電腦驅動器信息

    c#不使用windows api函數打開我的電腦和獲取電腦驅動器信息

    這篇文章主要介紹了c#不使用windows api函數打開我的電腦和電腦驅動器信息的方法,大家參考使用
    2013-12-12
  • C#開發(fā)WPF程序中的弱事件模式

    C#開發(fā)WPF程序中的弱事件模式

    這篇文章介紹了C#開發(fā)WPF程序中的弱事件模式,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-06-06

最新評論