且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows窗体中更改GroupBox的边框颜色

更新时间:2023-12-06 13:07:46

这很简单,只需触发groupbox_Paint事件

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 );
}


如何在C#.NET中更改GroupBox的边框颜色? [ ^ ]


Refer - [MSDN]更改GroupBox的边框颜色 [ ^ 一>

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]

this is simple just fire on groupbox_Paint Event
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);  
        }  


How to change border color of GroupBox in C#.NET?[^]


Refer - Second answer in [MSDN] Changing border color of GroupBox[^]