Change the background color of a VscrollBar
Asked Answered
J

2

1

Is it possible to change the background color of a VscrollBar? The best approach I have consulted is http://www.codeproject.com/Articles/624997/Enhanced-Scrollbar or http://www.codeproject.com/Articles/41869/Custom-Drawn-Scrollbar, but no exists BackColor property, and BackgroundImage not works.

I tried the simplest thing like:

public class ScrollBarEx : VScrollBar
{
    protected override void OnPaint(PaintEventArgs e)
    {
        base.BackColor = Color.Red;
        base.Invalidate();
    }
}

It does not work. Any suggestions?

Jacksmelt answered 21/12, 2015 at 15:33 Comment(2)
possible duplicate of: #25822586Schenk
Max: Is the same, there is no way to change the background colorJacksmelt
L
5

I built my own custom ScrollBar control based on http://www.codeproject.com/Articles/41869/Custom-Drawn-Scrollbar.

My custom ScrollBar comes with ready-to-use themes (VS 2019 Dark and VS 2019 Light). You can change the control background color by modifying the field _backColor or you can expose this private field with a property to allow you to change the background color from the code.

I have modified the original control to get rid of the 3D colors and replaced them with flat colors

Flat ScrollBar

Complete Flat ScrollBar control code in VB.NET https://gist.github.com/ahmedosama007/c1b0cd327d395a5698c1e17e96d0f8f9

Laufer answered 5/9, 2022 at 17:47 Comment(0)
B
1

Not much new info, but: you have to play around with Paint event and do custom drawing of your scrollbar, here is another link with this solution (custom drawing through Paint event) http://www.codeproject.com/Articles/14801/How-to-skin-scrollbars-for-Panels-in-C

Broch answered 21/12, 2015 at 16:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.