2012-04-30 79 views
4

試圖讓TableLayoutPanel中的某些標籤從其單元格的左上角移動到單元格的中心,我嘗試嘗試添加填充和/或利潤率。以編程方式爲標籤分配邊距和/或填充

但是,沒有我試過的作品。下面是我試過的代碼和結果:

// Setting the padding just cuts off the bottom part of the text 
//lbl.Padding = new System.Windows.Forms.Padding(1); 

// How to set Margin? 
//lbl.Margin = new System.Windows.Forms.Margin(1); <- This mimics "Padding" but is not recognized 
//lbl.Margin = new Thickness(6); <- This is the only example I could find, but it's for WPF 

回答

15

嘗試:

lbl.Margin = new Padding(1); 

您可能還想做的事:

​​
-4
labelName.Style.Add("Margin", "10px"); 
+1

的問題是有關的WinForms,這看起來像JavaScript? – RoadieRich

相關問題