Search code examples
c#vb.netsystem.drawing

How to change a SplitContainer border color?


I have the border style set to FixedSingle. How can I change the color of the fixed single line around the panels? Instead of black I need it to be a light grey.


Solution

  • Handle the Paint event for each the SplitterPanels contained in the SplitContainer and draw your own border using the ControlPaint.DrawBorder method.

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        AddHandler SplitContainer1.Panel1.Paint, AddressOf Panel_Paint
        AddHandler SplitContainer1.Panel2.Paint, AddressOf Panel_Paint
    End Sub
    
    Private Sub Panel_Paint(sender As Object, e As PaintEventArgs)
        ControlPaint.DrawBorder(e.Graphics, e.ClipRectangle, Color.LightGray, ButtonBorderStyle.Solid)
    End Sub