我需要在我的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