你如何改变边界的一组框的颜色? [英] How do you change the color of the border on a group box?

查看:217
本文介绍了你如何改变边界的一组框的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#.NET我试图以编程方式更改一个组框的边框颜色

In C#.NET I am trying to programmatically change the color of the border in a group box.

更​​新:当我工作的一个这个问题被问的WinForms系统之前,我们切换到.NET。

Update: This question was asked when I was working on a winforms system before we switched to .NET.

推荐答案

在以前的答案,一个更好的解决方案,包括该组的标签大楼框:

Building on the previous answer, a better solution that includes the label for the group box:

groupBox1.Paint += PaintBorderlessGroupBox;

private void PaintBorderlessGroupBox(object sender, PaintEventArgs p)
{
  GroupBox box = (GroupBox)sender;
  p.Graphics.Clear(SystemColors.Control);
  p.Graphics.DrawString(box.Text, box.Font, Brushes.Black, 0, 0);
}

您可能要调整文本的X / Y,但我的用这个正好。

You might want to adjust the x/y for the text, but for my use this is just right.

这篇关于你如何改变边界的一组框的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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