Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
Is it possible to change the border color of GroupBox in a Windows Forms application?

[Edit]Changed ASP.NET tag into WinForm tag, subject updated[/Edit]
Posted
Updated 29-Jul-13 21:32pm
v3
Comments
Boipelo 30-Jul-13 3:22am    
Google. I pasted your question as is in google, first result has the correct answer.
Prasad Khandekar 30-Jul-13 3:39am    
Hello Boipelo,

Please post the link as an aswer. So that Keerthi can accept it and close the question.

Regards,

this is simple just fire on groupbox_Paint Event
C#
private void groupBox1_Paint(object sender, PaintEventArgs e)  
        {  
            Graphics gfx = e.Graphics;  
            Pen p = new Pen(Color.Orange, 3);  
            gfx.DrawLine(p, 0, 5, 0, e.ClipRectangle.Height - 2);  
            gfx.DrawLine(p, 0, 5, 10, 5);  
            gfx.DrawLine(p, 62, 5, e.ClipRectangle.Width - 2, 5);  
            gfx.DrawLine(p, e.ClipRectangle.Width - 2, 5, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2);  
            gfx.DrawLine(p, e.ClipRectangle.Width - 2, e.ClipRectangle.Height - 2, 0, e.ClipRectangle.Height - 2);  
        }  
 
Share this answer
 
v2
Comments
Keerthi Kumar(Andar) 30-Jul-13 4:24am    
Thanks to Boipelo and Prasad
Am not trying to draw the group box from code behind, I want to change the border color of already added groupbox through tool box. In your Solution they are drawing the rectangle through paint and applying color and text to it.
[no name] 14-Mar-15 8:20am    
Nice...and Thanks for this code
 
Share this answer
 
v4
Refer - Second answer in [MSDN] Changing border color of GroupBox[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900