2012-04-30 14 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

試してみてください。

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

質問ですWinformsの程度、これを:またやりたいかもしれません

lbl.Margin = new Padding(1); 

javascriptのように見える? – RoadieRich

関連する問題