标签对齐设置为居中 [英] Label alignment set to center
本文介绍了标签对齐设置为居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
假设我们在表单上有一个标签,用于显示任何通知.我希望将其放置在表单的顶部中心.并且在收到通知时,标签应保留在表格的确切中心(左右边界,根据消息的长度而增大或缩小)
请分享您的想法,我应该如何使用此标签.
Hi guys !
let say we have a label on form for showing any notifications. i wish to place it at top center of form. and on notification the label should remain at exact center of form (left & right bounds, both grow or shrink on base of message length)
share your ideas please that what should i do with this label.
推荐答案
使用 ^ ]和TextAlign [
Use Dock[^] and TextAlign[^] property.
iosmac建议不起作用,因为默认情况下AutoSize
为true
.即使对接正确,由于此属性,标签也无法占据所有对接区域.
请执行以下操作:将Dock
设置为TopCenter
,MiddleCenter
或ButtomCenter
,将Dock
设置为Top
或Bottom
,将AutoSize
设置为false
.这样,标签将从左到右拉伸以占据父控件的整个宽度,并且文本本身(不是Label
控件)将居于Label
控件的中心.
它可以正常工作,经过测试.
—SA
What iosmac advised cannot work, because by defaultAutoSize
istrue
. Even when docking is correct, the label cannot take all dock area because of this property.
Do the following: setDock
toTopCenter
,MiddleCenter
orButtomCenter
,Dock
toTop
orBottom
andAutoSize
tofalse
. In this way, the label will stretch left-to-right to occupy full width of the parent control, and the text itself (notLabel
control) will be centered inside theLabel
control.
It works, tested.
—SA
这篇关于标签对齐设置为居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文