如何设置 GroupBox 标题颜色
在我的系统上,组框的标题始终为深蓝色,如何更改?
你怎么样更改组框上边框的颜色? 显示了如何覆盖标题和边框的绘制,但我不想处理视觉样式和绘制圆角等。
On my system, the caption of a groupbox is always a dark blue colour, how do I change this?
The answer to How do you change the color of the border on a group box? shows how I can override the drawing of the caption and border, but I don't want to have to deal with Visual Styles and drawing rounded corners and the like.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
以上对我没有帮助。
我在此处找到了解决方案 通过添加 GroupBox.Header 标签:
The above did not help me.
I found the solution here by adding the GroupBox.Header tag:
至少在Delphi中,标题只是字体颜色,你要确保parentfont是假的。 但这对你来说可能根本没有用,因为你标记了你的问题 .net
In Delphi at least, the caption is just the font color, you want to make sure parentfont is false. But that may not be useful at all to you since you tagged your question .net
设置
会更改组框中其他控件(如按钮、标签等)的前景色,如果您只需要更改组框的文本颜色,则在大多数情况下这是不受欢迎的。 一个简单的解决方法是
当然,如果您稍后以编程方式向组框添加控件,则上述代码可能毫无意义,但好处是您可以通过在代码中添加额外条件来处理所有这些情况。 为了双重确定,可以使用控件和前景色的键值对列表。
Setting
changes the forecolor of other controls like button, label etc residing inside the groupbox which has to be unwelcome in most cases if you only need to change the text colour of groupbox. A simple workaround will be
Of course the above code can be meaningless if you are adding controls programmatically later to the groupbox, but the good thing is you can handle all that situations by adding extra conditions in code. To be doubly sure, a list of keyvaluepair of control and forecolor can be employed.
ForeColor 是控制组框中文本颜色的属性。
ForeColor is the property that controls the color of the text in a groupbox.
这应该可以解决问题:
This ought to do the trick:
看来我可以通过将 ForeColor 设置为我想要的颜色并将 FlatStyle 设置为 Standard 来设置标题颜色。
如果 FlatStyle 为 System,或者为 Standard,并且 ForeColor 未更改为默认值,则标题颜色将设置为 XP 主题中指定的颜色。
It seems I can set the caption colour by setting the ForeColor to the colour I want and setting the FlatStyle to Standard.
If the FlatStyle is System, or if it's Standard and the ForeColor isn't changed from the default, then the caption color is set to the color specified in the XP Theme.