3

I'm developing a Winforms application and need to set design of scrollbar. I need to change colors of arrows, slider and background of a track. I found a ScrollBarRenderer on msdn msdn ScrollBarRenderer Info and now I don't understand how to set up rendering via methods like

ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics, ClientRectangle, ScrollBarState.Normal); // Draw the thumb and thumb grip in the current state. ScrollBarRenderer.DrawHorizontalThumb(e.Graphics, thumbRectangle, thumbState); ScrollBarRenderer.DrawHorizontalThumbGrip(e.Graphics, thumbRectangle, thumbState); 

This code is executed in OnPaint.

I'll be very grateful for any help.

1 Answer 1

3

Sadly the ScrollBar is just a wrapper around the native Win32 API, which doesn't expose the the colors of the bar.

Other controls allow you to extend a custom renderer and use that, but because the scroll bar simply links through to Win32 calls, you can't do that here.

The only way to achieve this is to create a custom draw scroll bar class extending from Control, as this example on Code Project shows.


http://www.codeproject.com/Articles/41869/Custom-Drawn-Scrollbar

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.