title: WinForm: Inherited Panel wont Autosize
body: <p>first of all: my English is pretty bad. I'm sorry if there are some grammar and writing errors.</p>
  
  <p>My question: </p>
  
  <p>Our company is using the same DLL for a lot of programs. In on of those multiused DLLs, we created some basic UI object, that are used very often. But we found a bug, when the DLL is used in a specific programm:</p>
  
  <p>My team created a panel via WinForm. Normaly it works great: Whenever you start a panel, the form is autosized according to the current free space it got. To realize this, we used following code: </p>
  
  <pre><code>this.tableLayoutPanelMain.AutoSize = true;
              this.tableLayoutPanelMain.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
  </code></pre>
  
  <p>No problems so far. But, after this specific panel is used again in the SAME program - I think this created panel is inherited somehow -  it wont autosize anymore. Instead it got the pre-defined size:  </p>
  
  <pre><code>this.tableLayoutPanelMain.Size = new System.Drawing.Size(341, 69);
  </code></pre>
  
  <p>I dont have any idea, why the panel isnt reloading again and autosizing again. The biggest issue here is, that I dont have access to the specific program, where this bug occurs and our DLL is used. I just know that this error somehow occours there. </p>
  
  <p>I am not a pro-programmer. But I think that it has something to do how they implemented the panel. I think, that they created it once, but never again. So there is just one panel, used pretty often. But while doing this, it wont refresh, nor using the autosize function aymore.</p>
  
  <p>To prevent this bug, I believe I somehow have to implement something like: constantly refresh, whenever used, please autosize.</p>
  
  <p>But I have absolutley no idea. I've never worked with winforms, just with XAML. So if anyone could help me with this, i would really appreciate it.</p>
  
  <p>The code:</p>
  
  <pre><code>    this.tableLayoutPanelMain.AutoSize = true;
      this.tableLayoutPanelMain.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
      this.tableLayoutPanelMain.ColumnCount = 3;
      this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
      this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 16F));
      this.tableLayoutPanelMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 218F));
      this.tableLayoutPanelMain.Controls.Add(this.panelPasswordRepetitionError, 1, 2);
      this.tableLayoutPanelMain.Controls.Add(this.txtRepetition, 2, 2);
      this.tableLayoutPanelMain.Controls.Add(this.lblPasswordRepetition, 0, 2);
      this.tableLayoutPanelMain.Controls.Add(this.panelPasswordError, 1, 0);
      this.tableLayoutPanelMain.Controls.Add(this.txtPassword, 2, 0);
      this.tableLayoutPanelMain.Controls.Add(this.panelDummy, 0, 1);
      this.tableLayoutPanelMain.Controls.Add(this.passwordQualityBox1, 2, 1);
      this.tableLayoutPanelMain.Dock = System.Windows.Forms.DockStyle.Fill;
      this.tableLayoutPanelMain.Location = new System.Drawing.Point(0, 0);
      this.tableLayoutPanelMain.Margin = new System.Windows.Forms.Padding(0);
      this.tableLayoutPanelMain.Name = "tableLayoutPanelMain";
      this.tableLayoutPanelMain.RowCount = 3;
      this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
      this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
      this.tableLayoutPanelMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
      this.tableLayoutPanelMain.Size = new System.Drawing.Size(341, 69);
      this.tableLayoutPanelMain.TabIndex = 0;
  </code></pre>
  
  <p>Forgot this:</p>
  
  <pre><code>// PDFPasswordView
  // 
  this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
  this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  this.AutoSize = true;
  this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
  this.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange;
  this.Controls.Add(this.tableLayoutPanelMain);
  this.DoubleBuffered = true;
  this.Margin = new System.Windows.Forms.Padding(0);
  this.Name = "PDFPasswordView";
  this.Size = new System.Drawing.Size(341, 69);
  this.Validated += new System.EventHandler(this.OnPDFPasswordViewValidated);
  this.tableLayoutPanelMain.ResumeLayout(false);
  this.tableLayoutPanelMain.PerformLayout();
  ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
  ((System.ComponentModel.ISupportInitialize)(this.markerProvider)).EndInit();
  this.ResumeLayout(false);
  this.PerformLayout();
  </code></pre>