C# 标签 AutoSize 添加填充
我在 Windows.Form 上有一个标签。我将标签上的 AutoSize 属性设置为 True,我注意到当我这样做时,它会用 ~5px 的白色背景填充右侧。我将 Padding 属性设置为 [0, 0, 0, 0]。有办法摆脱这个吗?
我希望标签的边界尽可能接近标签内的文本。
I have a Label on a Windows.Form. I set the AutoSize property on the label to True and I noticed that when I do that, it pads the right hand side with ~5px of white background. I have the Padding property set to [0, 0, 0, 0]. Is there a way to get rid of this?
I would like to get the bounds of the label as close as possible to the text within the label.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您只使用内边距和边距时,这是没有办法的。这是默认行为。
在上面的
Window
中,我设置了Padding
并将保证金
设置为[0,0,0,0]
。那 5 个像素仍然存在。如果您设置
FlatStyle = System
和AutoSize = False
您可以得到:在上面的
Window
中,您不再有这 5 个像素。There's no way when you use only padding and margin. That's the default behavior.
In the above
Window
I've set thePadding
andMargin
to[0,0,0,0]
. Those 5 pixels are still there.If you set
FlatStyle = System
andAutoSize = False
you can get this:In the above
Window
you don't have those 5 pixels anymore.好的,所以FlastStyle = System;自动调整大小=假;然后设置一个属性来计算宽度,如下所示:
}
Ok, so FlastStyle = System; AutoSize = false; and then set up a property that will calculate the width like this:
}