2011-11-25 56 views
4

我爲Windows窗體應用程序創建了一個用戶控件。它只有一個帶有四個單元格的TableLayoutPanel。單元格[0,0]和單元格[0,1]具有標籤。 Cell [1,0]有一個樹形視圖,單元格[1,1]有CheckedListBox。CheckedListBox停靠工作不正常

對於所有四個控件,我已設置對接到填充。這個奇怪的CheckedListBox看起來比TreeView小。有什麼方法可以正確對接控件嗎?

順便說一句,我使用的.Net 3.5和VS 2010

以下是設計文件代碼控制:

namespace UserControls 
{ 
    partial class LinkedContent 
    { 
     /// <summary> 
     /// Required designer variable. 
     /// </summary> 
     private System.ComponentModel.IContainer components = null; 

     /// <summary> 
     /// Clean up any resources being used. 
     /// </summary> 
     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 
     protected override void Dispose(bool disposing) 
     { 
      if (disposing && (components != null)) 
      { 
       components.Dispose(); 
      } 
      base.Dispose(disposing); 
     } 

     #region Component Designer generated code 

     /// <summary> 
     /// Required method for Designer support - do not modify 
     /// the contents of this method with the code editor. 
     /// </summary> 
     private void InitializeComponent() 
     { 
      this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); 
      this.lblContentGroups = new System.Windows.Forms.Label(); 
      this.lblModules = new System.Windows.Forms.Label(); 
      this.tvContent = new System.Windows.Forms.TreeView(); 
      this.chkListBoxModules = new System.Windows.Forms.CheckedListBox(); 
      this.tableLayoutPanel1.SuspendLayout(); 
      this.SuspendLayout(); 
      // 
      // tableLayoutPanel1 
      // 
      this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single; 
      this.tableLayoutPanel1.ColumnCount = 2; 
      this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 
      this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); 
      this.tableLayoutPanel1.Controls.Add(this.lblContentGroups, 0, 0); 
      this.tableLayoutPanel1.Controls.Add(this.lblModules, 1, 0); 
      this.tableLayoutPanel1.Controls.Add(this.tvContent, 0, 1); 
      this.tableLayoutPanel1.Controls.Add(this.chkListBoxModules, 1, 1); 
      this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; 
      this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); 
      this.tableLayoutPanel1.Name = "tableLayoutPanel1"; 
      this.tableLayoutPanel1.RowCount = 2; 
      this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 7.760532F)); 
      this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 92.23947F)); 
      this.tableLayoutPanel1.Size = new System.Drawing.Size(501, 451); 
      this.tableLayoutPanel1.TabIndex = 0; 
      // 
      // lblContentGroups 
      // 
      this.lblContentGroups.AutoSize = true; 
      this.lblContentGroups.Dock = System.Windows.Forms.DockStyle.Fill; 
      this.lblContentGroups.Location = new System.Drawing.Point(4, 1); 
      this.lblContentGroups.Name = "lblContentGroups"; 
      this.lblContentGroups.Size = new System.Drawing.Size(243, 34); 
      this.lblContentGroups.TabIndex = 0; 
      this.lblContentGroups.Text = "Content Groups"; 
      this.lblContentGroups.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 
      // 
      // lblModules 
      // 
      this.lblModules.AutoSize = true; 
      this.lblModules.Dock = System.Windows.Forms.DockStyle.Fill; 
      this.lblModules.Location = new System.Drawing.Point(254, 1); 
      this.lblModules.Name = "lblModules"; 
      this.lblModules.Size = new System.Drawing.Size(243, 34); 
      this.lblModules.TabIndex = 1; 
      this.lblModules.Text = "Modules"; 
      this.lblModules.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 
      // 
      // tvContent 
      // 
      this.tvContent.CheckBoxes = true; 
      this.tvContent.Dock = System.Windows.Forms.DockStyle.Fill; 
      this.tvContent.Location = new System.Drawing.Point(4, 39); 
      this.tvContent.Name = "tvContent"; 
      this.tvContent.Size = new System.Drawing.Size(243, 408); 
      this.tvContent.TabIndex = 2; 
      // 
      // chkListBoxModules 
      // 
      this.chkListBoxModules.Dock = System.Windows.Forms.DockStyle.Fill; 
      this.chkListBoxModules.FormattingEnabled = true; 
      this.chkListBoxModules.Location = new System.Drawing.Point(254, 39); 
      this.chkListBoxModules.Name = "chkListBoxModules"; 
      this.chkListBoxModules.Size = new System.Drawing.Size(243, 408); 
      this.chkListBoxModules.TabIndex = 3; 
      // 
      // LinkedContent 
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
      this.Controls.Add(this.tableLayoutPanel1); 
      this.Name = "LinkedContent"; 
      this.Size = new System.Drawing.Size(501, 451); 
      this.tableLayoutPanel1.ResumeLayout(false); 
      this.tableLayoutPanel1.PerformLayout(); 
      this.ResumeLayout(false); 

     } 

     #endregion 

     private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; 
     private System.Windows.Forms.Label lblContentGroups; 
     private System.Windows.Forms.Label lblModules; 
     private System.Windows.Forms.TreeView tvContent; 
     private System.Windows.Forms.CheckedListBox chkListBoxModules; 
    } 
} 
+1

有些代碼呢? – Mazen313

+0

你可以把截圖向我們展示它的樣子嗎? –

+0

與給定的信息我無法重現所描述的行爲。請爲我們提供一些代碼和截圖 - thx –

回答

8

檢查以確保IntegralHeight屬性未設置。它默認爲true。

從MSDN鏈接以上:

當該屬性被設置爲真,則控制自動調整 ,以確保一個項目是不是部分顯示。如果您想要 根據表單的空間 要求維護列表框的原始大小,請將此屬性設置爲false。

+0

完美。非常感謝Mark。 – danish

+0

@danish您的歡迎 –