How to change Panel Border Color

yogeshkmrsoni002 picture yogeshkmrsoni002 · Jan 8, 2014 · Viewed 74.1k times · Source

IDE : Visual Studio, C#.net,Type= Windows form application

Hi, In Panel Properties I have set the border style to Fixed Single".
when I am running my application its giving me Grey color. I don't know How to change the border color. I have tried in Paint event of panel

private void HCp_Paint(object sender, PaintEventArgs e)
{
    Panel p = sender as Panel;
    ControlPaint.DrawBorder(e.Graphics, p.DisplayRectangle, Color.Yellow, ButtonBorderStyle.Inset);
}

its giving me border like this:

http://i772.photobucket.com/albums/yy9/yogeshkmrsoni/giving_zps877730fc.png

and I want fixed single border like this:

http://i772.photobucket.com/albums/yy9/yogeshkmrsoni/want_zps081e3591.png

I am able to get FixedSingle Border but it is in Grey color which is default by system or IDE.

So pls suggest me how I make it in yellow color.

Answer

Raihan Al-Mamun picture Raihan Al-Mamun · Nov 13, 2018

If you don't want to make a custom panel as suggested in @Sinatr's answer you can draw the border yourself:

private void panel1_Paint(object sender, PaintEventArgs e)
{
     ControlPaint.DrawBorder(e.Graphics, this.panel1.ClientRectangle, Color.DarkBlue, ButtonBorderStyle.Solid);
}