2013-02-12 53 views
0

我有了一個flowLayoutpanel1我把一些小程序OD fynamically創建的標籤在它像這樣:確定動態標籤間距

enter image description here

,但我想這些標籤有某種差距彼此之間所以他們不感動 和lbl.SetBounds();似乎並沒有在這裏工作。

這是我正在測試的代碼?

flowLayoutPanel1.Controls.Clear(); 
      int length = 9; 
      for (int i = 0; i < length; i++) 
      { 
       Label lbl = new Label(); 
       lbl.Name = i.ToString(); 
       lbl.Text = "Label " + i.ToString(); 
       lbl.AutoSize = true; 
       lbl.Font = new Font("Ariel", 10); 
       lbl.SetBounds(0, 20, 70, 70); 
       lbl.BorderStyle = BorderStyle.FixedSingle; 
       flowLayoutPanel1.Controls.Add(lbl); 
      } 

有關如何獲得間距的任何建議?

回答

2

如果你想增加文本和輪廓之間的空間使用:

lbl.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); 

with margin

如果你想之間的輪廓,使用添加空間:

lbl.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); 

with padding

或兩者兼有