Delphi:TPanel 和文本缩进
我怎样才能使视图像黄色矩形一样。使用 TPanel + 颜色?如果是的话,文本从左侧缩进怎么样?
感谢您的帮助和建议!
How can I make the view like in the Yellow rectangle. Using TPanel + Color? If yes what about an indent of the text from the left?
Thanks for help and advices!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法是使用
TPanel
。将ParentBackground
设置为false
,将BevelOuter
设置为bvNone
,将Font.Color
设置为>clWhite
、Font.Style
为[fsBold]
,Color
为您想要的背景颜色。然后只需在Caption
属性中的文本前面放置一两个空格,例如'这是一个普通的 TPanel。'
。更优雅的解决方案是编写自定义控件。这真的很容易。例子:
The simplest way is to use a
TPanel
. SetParentBackground
tofalse
,BevelOuter
tobvNone
,Font.Color
toclWhite
,Font.Style
to[fsBold]
and theColor
to the background colour you want. Then simply put one or two spaces in front of your text in theCaption
property, like' This is an ordinary TPanel.'
.A more elegant soution is to write a custom control. This is really easy. Example:
将标签放入面板中,缩进(设置 Left 属性 > 0)并正确设置面板颜色。
Drop a Label into the panel, indented (set the Left property > 0) and set the panel color correctly.