Custom scroll bar renderer

Posted by: kbj on 22 December 2019, 12:45 am EST

  • Posted 22 December 2019, 12:45 am EST

    In order to have a cohesive user experience, I would like the fpspread scrollbars to look and act the same as say the scroll bars in the C1InputPanel. The FlatScrollBarRenderer is close. I am trying to write my own renderer implementing IScrollBarRenderer) but cannot see how any of the drawing subs know if the element is being hovered over or pressed.
    Thanks,
    Kingman
  • Replied 22 December 2019, 6:00 pm EST

    Hello,

    You can use the "EnhancedScrollBarRenderer" to customize the scrollbar of the spread. Please refer to the following line of code:


    FarPoint.Win.Spread.EnhancedScrollBarRenderer enhancedScrollBarRenderer1 = new FarPoint.Win.Spread.EnhancedScrollBarRenderer();
    enhancedScrollBarRenderer1.ArrowColor = System.Drawing.Color.Navy;
    enhancedScrollBarRenderer1.ArrowHoveredColor = System.Drawing.Color.Navy;
    enhancedScrollBarRenderer1.ArrowSelectedColor = System.Drawing.Color.Navy;
    enhancedScrollBarRenderer1.ButtonBackgroundColor = System.Drawing.Color.LightSteelBlue;
    enhancedScrollBarRenderer1.ButtonBorderColor = System.Drawing.Color.SteelBlue;
    enhancedScrollBarRenderer1.ButtonHoveredBackgroundColor = System.Drawing.Color.DeepSkyBlue;
    enhancedScrollBarRenderer1.ButtonHoveredBorderColor = System.Drawing.Color.DeepSkyBlue;
    enhancedScrollBarRenderer1.ButtonSelectedBackgroundColor = System.Drawing.Color.SteelBlue;
    enhancedScrollBarRenderer1.ButtonSelectedBorderColor = System.Drawing.Color.LightSteelBlue;
    enhancedScrollBarRenderer1.TrackBarBackgroundColor = System.Drawing.Color.LightSkyBlue;
    enhancedScrollBarRenderer1.TrackBarSelectedBackgroundColor = System.Drawing.Color.SteelBlue;
    this.fpSpread1.HorizontalScrollBar.Renderer = enhancedScrollBarRenderer1;



    Hope it helps.

    Thanks,
    Mohit
  • Replied 23 December 2019, 1:22 am EST

    Hi Mohit,
    The EnhancedScrollBarRenderer does not look exactly like the scrollbars found in The C1 controls. So if I am still wishing to write my own renderer that will perform and look as they do. So my question stands. How do I know the hover and pressed states of the parts of the scroll bars when they are to be painted? Since the FlatScrollBarRenderer does this using the IScrollBarRenderer albeit with inaccessible hover and pressed colors, there must be a way.
    -Kingman
  • Replied 23 December 2019, 10:31 pm EST

    Hello,

    I have escalated the issue to our development team(SPNET-1260) and will inform you once I get any information from them.

    Thanks,
  • Replied 1 February 2020, 9:23 am EST

    It's been over a month, any update?
  • Replied 3 February 2020, 12:58 am EST

    Hello,

    I have asked the development team for an update on the issue.

    Thanks,
    Mohit
  • Replied 4 February 2020, 11:15 pm EST

    Hello,

    Currently, it is not possible to add a custom scrollbar in the spread as of now.

    Sorry for the inconvenience caused to you.

    Thanks,
    Mohit
  • Replied 5 February 2020, 4:37 pm EST

    Hello,

    FYI, our development has taken this into consideration. If they found it feasible, they will add the same in a future build of spread.

    Thanks,
    Mohit
  • Marked as Answer

    Replied 24 April 2020, 2:01 am EST

    Hello,

    I am glad to tell you that your issue has fixed now. Please download the latest version:
    https://cdn.grapecity.com/SpreadNET/installer/13.0.20201.0/Spread.NET+Installer.exe
    set render for scrollbar:
    this.fpSpread1.HorizontalScrollBar.Renderer = new customscrollbar();

    public class customscrollbar :FlatScrollBarRenderer, IScrollBarRenderer
    {

    object ICloneable.Clone()

    { return this; }
    void IScrollBarRenderer.DrawArrowButton(Graphics g, Rectangle bounds, FpScrollBarButton element)
    {
    switch (element.State)

    { case System.Windows.Forms.VisualStyles.ScrollBarState.Normal: //todo break; case System.Windows.Forms.VisualStyles.ScrollBarState.Hot: //todo break; case System.Windows.Forms.VisualStyles.ScrollBarState.Pressed: //todo break; case System.Windows.Forms.VisualStyles.ScrollBarState.Disabled: //todo break; default: break; }
    base.DrawArrowButton(g, bounds, element);
    }
    }


    Hope it helps.

    Thanks,
    Mohit
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels