I've got a TableLayoutPanel in which I create rows of the following "on the fly":
Label TextBox TextBox
Label TextBox TextBox
Label TextBox TextBox
I create the controls like this:
From the Designer.cs file:
I might have a couple of misunderstanding etc. with regards to the sizing, size types etc.
The problem is that the space between the cells is too big, and I'm running out of space when I want to increase the size of the TextBoxes.
So: Is there a way to set the spacing between the controls/cells in the TableLayoutPanel? Since I'm not creating them by creating objects and naming them, am I missing out on something? The reason I'm creating them like this is that I have methods for adding and removing rows in the layout.
Label TextBox TextBox
Label TextBox TextBox
Label TextBox TextBox
I create the controls like this:
C#:
for (int i = 0; i < Properties.Settings.Default.rowcount; i++) {
userPanel.Controls.Add(new Label() { Text = "Login" });
userPanel.Controls.Add(new TextBox());
userPanel.Controls.Add(new TextBox()); }
From the Designer.cs file:
C#:
this.userPanel.AutoSize = true;
this.userPanel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.userPanel.ColumnCount = 3;
this.userPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 60F));
this.userPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 165F));
this.userPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 165F));
this.userPanel.Location = new System.Drawing.Point(12, 153);
this.userPanel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 35);
this.userPanel.Name = "userPanel";
this.userPanel.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.userPanel.RowCount = 3;
this.userPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.userPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.userPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.userPanel.Size = new System.Drawing.Size(390, 0);
this.userPanel.TabIndex = 6;
I might have a couple of misunderstanding etc. with regards to the sizing, size types etc.
The problem is that the space between the cells is too big, and I'm running out of space when I want to increase the size of the TextBoxes.
So: Is there a way to set the spacing between the controls/cells in the TableLayoutPanel? Since I'm not creating them by creating objects and naming them, am I missing out on something? The reason I'm creating them like this is that I have methods for adding and removing rows in the layout.