In C#.NET I am trying to programmatically change the color of the border in a group box.
Update: This question was asked when I was working on a winforms system before we switched to .NET.
In C#.NET I am trying to programmatically change the color of the border in a group box.
Update: This question was asked when I was working on a winforms system before we switched to .NET.
Just add paint event.
Just set the paint action on any object (not just buttons) to this method to draw a border.
It still wont be pretty and rounded like the original, but it is much simpler.
FWIW, this is the implementation I used. It's a child of GroupBox but allows setting not only the BorderColor, but also the thickness of the border and the radius of the rounded corners. Also, you can set the amount of indent you want for the GroupBox label, and using a negative indent indents from the right side.
To make it work, you also have to extend the base Graphics class (Note: this is derived from some code I found on here once when I was trying to create a rounded-corners Panel control, but I can't find the original post to link here):
Building on the previous answer, a better solution that includes the label for the group box:
You might want to adjust the x/y for the text, but for my use this is just right.
I'm not sure this applies to every case, but thanks to this thread, we quickly hooked into the Paint event programmatically using:
Cheers!
I have achieved same border with something which might be simpler to understand for newbies:
I do not know, may be it helps someone looking to achieve this border adjustment thing.