Panel BorderColor

Posted on 2005-04-27
Medium Priority
Last Modified: 2009-07-29
hi all,
 how do i set the Panel BorderColor

Question by:madmare

Accepted Solution

nachiket earned 1000 total points
ID: 13875543
as per my knowledge you can not... you can only change the Border Style!!

However you have a workaround when u use 2 panels.. u can also extend a panel class and implement your own panel in the following way

code using 2 panels
                                                Panel p1 = new Panel();
                  Panel  p2 = new Panel();
                  Color borderColor = Color.Red ;
                  Color foreColor = Color.Green ;
                  int borderWidth = 5;

                  p1.Top =20;
                  p1.Width = 100;
                  p1.Height = 100;
                  p1.BackColor = borderColor;

                  p2.Top =borderWidth;
                  p2.Width = p1.Width - 2*borderWidth;
                  p2.Height = p1.Height - 2*borderWidth;
                  p2.BackColor = foreColor;
LVL 20

Expert Comment

ID: 13879308
Here is some code how to change the border color of a panel:
It's VB but you can either compile it from VB and use it directly in C# or rewrite it in C#, which is not difficult.

Expert Comment

ID: 13881156
You can also attach an event handler to the panel's paint method and draw a rectangle onto the form.  I've used this numerous times doing .NET Compact Framework stuff; not sure if it's the most efficient way to do it on the standard framework though.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Integration Management Part 2
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question