C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
When I add a control to a tablelayout panel, it inserts the control at the beginning of the panel instead of at the last.
tableLayoutPanel1.Controls.Add(mTAButtonRounded, tableLayoutPanel1.ColumnCount + 1, 0);
tableLayoutPanel1.ColumnStyles.Clear();
for (int i = 0; i < tableLayoutPanel1.ColumnCount; i++)
{
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
}
If I do a test, the Button is inserted in last column/last row =>
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button button1;
then :
tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
tableLayoutPanel1.ColumnCount = 3;
tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
tableLayoutPanel1.Location = new System.Drawing.Point(10, 10);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 5;
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F));
tableLayoutPanel1.Size = new System.Drawing.Size(400, 200);
tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Outset;
button1 = new System.Windows.Forms.Button();
button1.Name = "button1";
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
tableLayoutPanel1.Controls.Add(button1, tableLayoutPanel1.ColumnCount -1, tableLayoutPanel1.RowCount -1);
Controls.Add(tableLayoutPanel1);