我正在尝试在 winforms 应用程序中创建动态文本框。它通过不正确地创建正确的空间。我在这里做错了什么。
private void createTextBoxes()
{
int width = 69;
int height = 20;
int spacing = 32;
TextBox[] subAmt = new TextBox[12];
for (int i = 0; i <= 11; ++i)
{
subAmt[i] = new TextBox();
subAmt[i].Size = new Size(width, height);
subAmt[i].Margin = new Padding(3);
subAmt[i].Location = new Point(279, (i * height) + spacing); // <-- this is should space it out but does not
subAmt[i].KeyPress += new KeyPressEventHandler(txtAmt_KeyPress);
plSubscription.Controls.Add(subAmt[i]);
}
}
我有类似的组合框代码,它似乎正确地间隔
private void createCombo()
{
int width = 79;
int height = 24;
int spacing = 28;
for (int i = 0; i <= 11; ++i)
{
ComboBox newBox = new ComboBox();
newBox.Name = "SubYears";
newBox.DropDownStyle = ComboBoxStyle.DropDownList;
newBox.Size = new Size(width, height);
newBox.Location = new Point(145, (i * height) + spacing);
plSubscription.Controls.Add(newBox);
fillComboData(newBox);
}
}
这是组合框和文本框的屏幕截图