gpt4 book ai didi

c# - 以编程方式为标签分配边距和/或填充

转载 作者:太空狗 更新时间:2023-10-30 00:20:36 26 4
gpt4 key购买 nike

在尝试让 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

最佳答案

尝试:

lbl.Margin = new Padding(1);

你可能还想做:

lbl.Dock = DockStyle.Fill;
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.AutoSize = false;

关于c# - 以编程方式为标签分配边距和/或填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10390904/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com