标签对齐设置为居中 [英] Label alignment set to center

查看:164
本文介绍了标签对齐设置为居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!
假设我们在表单上有一个标签,用于显示任何通知.我希望将其放置在表单的顶部中心.并且在收到通知时,标签应保留在表格的确切中心(左右边界,根据消息的长度而增大或缩小)
请分享您的想法,我应该如何使用此标签.

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建议不起作用,因为默认情况下AutoSizetrue.即使对接正确,由于此属性,标签也无法占据所有对接区域.

请执行以下操作:将Dock设置为TopCenterMiddleCenterButtomCenter,将Dock设置为TopBottom,将AutoSize设置为false.这样,标签将从左到右拉伸以占据父控件的整个宽度,并且文本本身(不是Label控件)将居于Label控件的中心.

它可以正常工作,经过测试.

—SA
What iosmac advised cannot work, because by default AutoSize is true. Even when docking is correct, the label cannot take all dock area because of this property.

Do the following: set Dock to TopCenter, MiddleCenter or ButtomCenter, Dock to Top or Bottom and AutoSize to false. In this way, the label will stretch left-to-right to occupy full width of the parent control, and the text itself (not Label control) will be centered inside the Label control.

It works, tested.

—SA


这篇关于标签对齐设置为居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆