5

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
4

2 に答える 2

16

試す:

lbl.Margin = new Padding(1);

あなたもやりたいかもしれません:

lbl.Dock = DockStyle.Fill;
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.AutoSize = false;
于 2012-04-30T21:38:53.837 に答える
-6
labelName.Style.Add("Margin", "10px");
于 2015-02-06T14:25:28.120 に答える