无法在项目保存或其他更改后调整表格TableLayoutPanel

时间:2013-10-26 14:57:45

标签: winforms tablelayoutpanel

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

没有变化的例子(白色正方形只是照片..):

example2 http://dl.dropbox.com/s/08zhm19264r3qzf/original.jpg

使用边框调整大小示例:

example3 http://dl.dropbox.com/s/gelxjb8s2ip5bzj/after.jpg

这里它应该根据调整大小的边框进行相应缩放,但事实并非如此。我无法在google中找到接近我的情况的答案,但我做错了什么,因为我第一次创建并调整表格大小时,它完全按照我的意愿运行。

为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);

2 个答案:

答案 0 :(得分:2)

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

答案 1 :(得分:1)

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

第二张图片没有拖动句柄,这意味着它是在运行时拍摄的?你有没有改变FORM的大小?

使用您需要的表单使TableLayoutPanel更改大小:

  1. 使用TableLayoutPanel的Anchor()属性并将其全部打开 四方面。

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

  3. 哪种方法更好取决于您的整体表单布局,我们无法看到。