Panel BorderColor

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

Question by:madmare
    LVL 4

    Accepted Solution

    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

    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.
    LVL 9

    Expert Comment

    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

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now