如何在 C# 中的 Windows 窗体上更改 Groupbox 的边框粗细?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10997977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-09 16:03:41  来源:igfitidea点击:

How can I change the border thickness of a Groupbox on a windows form in C#?

c#winformsgroupbox

提问by asdasdad

I didn't find any solution that helped me on the older questions on SO... Is it possible to make them thicker or just more visible by changing the color? If yes, some code would be great... or just a hint how to do it...

我没有找到任何解决方案可以帮助我解决关于 SO 的旧问题......是否可以通过更改颜色使它们更厚或更明显?如果是的话,一些代码会很棒......或者只是一个提示如何去做......

采纳答案by SwDevMan81

You'll need to make a custom GroupBoxcontrol. See The Grouper - A Custom Groupbox Control

您需要制作一个自定义控件GroupBox。请参阅Grouper - 自定义 Groupbox 控件

回答by Jake1164

GroupBox is a custom drawn .Net control. You will need to hook into the Paint event, or derive from the GroupBox and override the OnPaint method, determine where the existing lines are being drawn and then draw overtop of them with wider lines to achieve the thicker border. Or you can create a custom control and paint everything yourself.

GroupBox 是一个自定义绘制的 .Net 控件。您需要挂钩 Paint 事件,或从 GroupBox 派生并覆盖 OnPaint 方法,确定绘制现有线条的位置,然后用更宽的线条在它们上面绘制以获得更粗的边框。或者您可以创建自定义控件并自己绘制所有内容。