Pat*_*ald 4 .net c# vb.net winforms
我希望在表格上有一些标签,其字体颜色与我的组框上的标题相同,而且如果用户在其系统上应用了不同的主题,我希望这些颜色更改.
我可以在不更改默认的GroupBox标题的情况下执行此操作吗?
更新:
我已经尝试将Label ForeColor设置为ActiveCaption,这对于默认(蓝色)方案看起来没问题,但是当我将方案更改为Olive Green时,标签和组框标题不一样.
此外,GroupBox正常行为是将FlatStyle设置为Standard将标题颜色设置为ForeColor,但是要创建新的GroupBox并将其ForeColor设置为ControlText,您必须首先将其设置为ControlText以外的其他内容,然后再将其设置回来.(如果你不遵循我的意思,那就试试吧.)
Han*_*ant 10
嗯,同样的问题?我会重复我的帖子:
using System.Windows.Forms.VisualStyles;
...
public Form1()
{
InitializeComponent();
if (Application.RenderWithVisualStyles)
{
VisualStyleRenderer rndr = new VisualStyleRenderer(VisualStyleElement.Button.GroupBox.Normal);
Color c = rndr.GetColor(ColorProperty.TextColor);
label1.ForeColor = c;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
32043 次 |
最近记录: |