我需要在我的WinForm应用程序的表单上放置“x”个标签。下面的功能已经做到了。我缺少的是能够增加每个标签之间的差距,而不增加标签的尺寸。我知道这可能是简单的,但对于我的生活,我似乎无法弄清楚。我提前为这样一个愚蠢的问题道歉。如何增加网格中动态添加的标签之间的差距?
private void AddUserControl()
{
int ucHeight = 60;
int ucWidth = 320;
int spacer = 20;
int start_x = 10;
int start_y = 10;
int NumOfRows = 6;
int NumOfColumns = 3;
int totalProblems = 17;
int ucCounter = 0;
for (int x = 0; x < NumOfRows; x++)
{
for (int y = 0; y < NumOfColumns; y++)
{
if (ucCounter < totalProblems)
{
Label myLabel = new Label();
myLabel.Top = start_x + (x * ucHeight + spacer);
myLabel.Left = start_y + (y * ucWidth + spacer);
myLabel.Width = ucWidth;
myLabel.Height = ucHeight;
this.Controls.Add(myLabel);
ucCounter++;
}
}
}
}
你想说gap而不是gab? – om471987 2012-02-23 22:29:25