2

我遇到了一个问题TableLayoutPanel。我已经配置我的表列和行的大小大部分是动态的,但是在我保存或完成其他更改后动态缩放不起作用(不能说这个问题究竟是什么时候开始的)并且我正在尝试调整表的大小边界。我的表配置如下所示: example1 http://dl.dropbox.com/s/4ayi073x6xfxokb/configuration.jpg

没有变化的例子(白色方块只是照片编辑..):

示例2 http://dl.dropbox.com/s/08zhm19264r3qzf/original.jpg

使用边框调整大小示例:

示例 3 http://dl.dropbox.com/s/gelxjb8s2ip5bzj/after.jpg

在这里,它应该已经根据调整后的边框进行了相应的缩放,但事实并非如此。我在谷歌中找不到与我的情况相近的答案,但我做错了什么,因为当我第一次创建和调整表格大小时,它可以按我的意愿完美运行。

为 TableLayoutPanel 添加了 Designer.cs 代码:

    // 
    // tableLayoutPanel2
    // 
    this.tableLayoutPanel2.ColumnCount = 5;
    this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50F));
    this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
    this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
    this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
    this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
    this.tableLayoutPanel2.Controls.Add(this.buttonFirstClockSecondDay_Type_A, 3, 1);
    this.tableLayoutPanel2.Controls.Add(this.textBox1, 1, 0);
    this.tableLayoutPanel2.Controls.Add(this.textBox2, 2, 0);
    this.tableLayoutPanel2.Controls.Add(this.label5, 0, 1);
    this.tableLayoutPanel2.Controls.Add(this.label1, 0, 3);
    this.tableLayoutPanel2.Controls.Add(this.label6, 0, 5);
    this.tableLayoutPanel2.Controls.Add(this.label7, 0, 7);
    this.tableLayoutPanel2.Controls.Add(this.buttonFirstClockFirstDay_Type_A, 1, 1);
    this.tableLayoutPanel2.Controls.Add(this.buttonFirstClockFirstDay_Type_B, 1, 2);
    this.tableLayoutPanel2.Controls.Add(this.buttonSecondClockFirstDay_Type_A, 1, 3);
    this.tableLayoutPanel2.Controls.Add(this.buttonSecondClockFirstDay_Type_B, 1, 4);
    this.tableLayoutPanel2.Controls.Add(this.buttonFirstClockSecondDay_Type_B, 3, 2);
    this.tableLayoutPanel2.Controls.Add(this.buttonSecondClockSecondDay_Type_A, 3, 3);
    this.tableLayoutPanel2.Controls.Add(this.buttonSecondClockSecondDay_Type_B, 3, 4);
    this.tableLayoutPanel2.Controls.Add(this.buttonThirdClockFirstDay_Type_A, 1, 5);
    this.tableLayoutPanel2.Controls.Add(this.buttonThirdClockFirstDay_Type_B, 1, 6);
    this.tableLayoutPanel2.Controls.Add(this.buttonFourthClockFirstDay_Type_A, 1, 7);
    this.tableLayoutPanel2.Controls.Add(this.buttonFourthClockFirstDay_Type_B, 1, 8);
    this.tableLayoutPanel2.Controls.Add(this.buttonThirdClockSecondDay_Type_A, 3, 5);
    this.tableLayoutPanel2.Controls.Add(this.buttonThirdClockSecondDay_Type_B, 3, 6);
    this.tableLayoutPanel2.Controls.Add(this.buttonFourthClockSecondDay_Type_A, 3, 7);
    this.tableLayoutPanel2.Controls.Add(this.buttonFourthClockSecondDay_Type_B, 3, 8);
    this.tableLayoutPanel2.Controls.Add(this.label3, 2, 1);
    this.tableLayoutPanel2.Controls.Add(this.label2, 2, 2);
    this.tableLayoutPanel2.Controls.Add(this.label8, 2, 3);
    this.tableLayoutPanel2.Controls.Add(this.label4, 2, 4);
    this.tableLayoutPanel2.Controls.Add(this.label14, 2, 5);
    this.tableLayoutPanel2.Controls.Add(this.label13, 2, 6);
    this.tableLayoutPanel2.Controls.Add(this.label15, 2, 7);
    this.tableLayoutPanel2.Controls.Add(this.label19, 2, 8);
    this.tableLayoutPanel2.Controls.Add(this.label10, 4, 1);
    this.tableLayoutPanel2.Controls.Add(this.label11, 4, 2);
    this.tableLayoutPanel2.Controls.Add(this.label9, 4, 3);
    this.tableLayoutPanel2.Controls.Add(this.label12, 4, 4);
    this.tableLayoutPanel2.Controls.Add(this.label17, 4, 5);
    this.tableLayoutPanel2.Controls.Add(this.label18, 4, 6);
    this.tableLayoutPanel2.Controls.Add(this.label16, 4, 7);
    this.tableLayoutPanel2.Controls.Add(this.label20, 4, 8);
    this.tableLayoutPanel2.Location = new System.Drawing.Point(382, 56);
    this.tableLayoutPanel2.Name = "tableLayoutPanel2";
    this.tableLayoutPanel2.RowCount = 9;
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F));
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F));
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F));
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F));
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F));
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F));
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F));
    this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F));
    this.tableLayoutPanel2.Size = new System.Drawing.Size(437, 288);
    this.tableLayoutPanel2.TabIndex = 6;
    this.tableLayoutPanel2.Paint += new System.Windows.Forms.PaintEventHandler(this.tableLayoutPanel2_Paint);
4

2 回答 2

3

由于某种原因,重新加载解决方案后它再次起作用。为什么它以前不起作用是一个谜。

于 2013-11-10T02:27:07.167 回答
1

第一张图片有拖动手柄,表明它是在设计时拍摄的。

第二张图片没有拖动手柄,这意味着它是在运行时拍摄的?您是否更改了表格的大小?

要使用 Form 更改 TableLayoutPanel 的大小,您需要:

  1. 使用 TableLayoutPanel 的 Anchor() 属性并打开所有四个面。

  2. 将 TableLayoutPanel 的 Dock() 属性设置为 Fill。

哪种方法更好取决于您的整体表单布局,这是我们看不到的。

于 2013-10-26T15:19:44.097 回答