Specific renderer of scrollbar

SyntaxEditor for Windows Forms Forum

Posted 9 years ago by Iurii Gazin
Version: 4.0.0282
Hi. How can I write specific renderer for a scrollbar only?
We are using Infragistic in our project, and need to set up SyntaxEditor, so his scroll bar would be looking just the same as Infragistic.
How can I do so?
I tried to inherit VisualStudio2005SyntaxEditorRenderer, and override DrawScrollBar<smth> methods. But I just couldn`t get, how to render for example scrollbar slider. I have only Button and Background methods.
And what logic should I use, to "connect" my drawn scroll bar with syntaxEditor?

Thanks for help

Comments (3)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA

There are 4 methods you can override: DrawScrollBarBackground, DrawScrollBarBlockBackground, DrawScrollBarButton, and DrawScrollBarThumb.

You can either set your custom renderer to the Renderer property of each SyntaxEditor or you can register it as the global default by doing this:
UIRendererManager.RegisterRendererFactory(typeof(ISyntaxEditorRenderer), yourfactory, true);
The "yourfactory" must be a class that implements IUIRendererFactory like this:
IUIRenderer IUIRendererFactory.CreateRenderer() {
    return new YourRenderer();

Actipro Software Support

Posted 9 years ago by Iurii Gazin
Tnx for your answer.

Yeah, I got this. I have question about implementation...
For example, how I imaging this:
I realize own scrollbar in my code (for example WinForms scrollbar). I set up slider width, sign on scollbar events, slider down, slider up or smth (I`m sorry if this isn`t how WinForms scollbar working, I don`t know, but I think - it is smth like this).
This scrollbar I should render by parts, coz your renderer implementation is separating buttons and slider - I don`t know, how to do this.
This is so difficult, does SyntaxEditor have functionality to simplify this?
Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Iurii,

Sorry you only use 3 of those methods for the actual scrollbar and they are extremely easy to use. Here's our default code for them with windows classic theme:
public override void DrawScrollBarBackground(PaintEventArgs e, Rectangle bounds, ActiproSoftware.WinUICore.ScrollBar scrollBar) {
    // Draw the background using a Windows Classic appearance
    HatchedBackgroundFill.Draw(e.Graphics, bounds, SystemColors.ControlLightLight, SystemColors.ScrollBar);

public override void DrawScrollBarButton(PaintEventArgs e, Rectangle bounds, ScrollBarButton button) {
    // Get the state
    ButtonState state = ButtonState.Normal;
    // Draw a border if enabled
    UIElementDrawState drawState = button.GetDrawState();
    if ((drawState & UIElementDrawState.Disabled) == UIElementDrawState.Disabled)
        state = ButtonState.Inactive;
    else if ((drawState & (UIElementDrawState.Hot | UIElementDrawState.Pressed)) == (UIElementDrawState.Hot | UIElementDrawState.Pressed))
        state = ButtonState.Pushed;

    // Draw the button
    if (button.CommandLink.Command == button.ScrollBar.DecreaseSmallCommand) {
        // Decrease button
        ControlPaint.DrawScrollButton(e.Graphics, bounds, 
            (button.ScrollBar.Orientation == Orientation.Horizontal ? ScrollButton.Left : ScrollButton.Up), state);
    else if (button.CommandLink.Command == button.ScrollBar.IncreaseSmallCommand) {
        // Increase button
        ControlPaint.DrawScrollButton(e.Graphics, bounds, 
            (button.ScrollBar.Orientation == Orientation.Horizontal ? ScrollButton.Right : ScrollButton.Down), state);

public override void DrawScrollBarThumb(PaintEventArgs e, Rectangle bounds, ScrollBarThumb thumb) {
    // If the scrollbar is enabled...
    if (thumb.ScrollBar.Enabled) {
        // Draw the thumb/gripper using a Windows Classic appearance
        e.Graphics.FillRectangle(SystemBrushes.Control, bounds);
        e.Graphics.DrawLine(SystemPens.ControlLight, bounds.Left, bounds.Bottom - 2, bounds.Left, bounds.Top);
        e.Graphics.DrawLine(SystemPens.ControlLight, bounds.Left, bounds.Top, bounds.Right - 2, bounds.Top);
        e.Graphics.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Top, bounds.Right - 1, bounds.Bottom - 1);
        e.Graphics.DrawLine(SystemPens.ControlDarkDark, bounds.Right - 1, bounds.Bottom - 1, bounds.Left, bounds.Bottom - 1);
        e.Graphics.DrawLine(SystemPens.ControlLightLight, bounds.Left + 1, bounds.Bottom - 3, bounds.Left + 1, bounds.Top + 1);
        e.Graphics.DrawLine(SystemPens.ControlLightLight, bounds.Left + 1, bounds.Top + 1, bounds.Right - 3, bounds.Top + 1);
        e.Graphics.DrawLine(SystemPens.ControlDark, bounds.Right - 2, bounds.Top + 1, bounds.Right - 2, bounds.Bottom - 2);
        e.Graphics.DrawLine(SystemPens.ControlDark, bounds.Right - 2, bounds.Bottom - 2, bounds.Left + 1, bounds.Bottom - 2);

Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.