.Net5 FlexGrid Scrollbar style

Posted by: frugamas on 5 November 2021, 5:02 pm EST

    • Post Options:
    • Link

    Posted 5 November 2021, 5:02 pm EST

    I’m incorporating the .NET 5 version of the FlexGrid into our application. The new hidden with auto-show style of the FlexGrid scrollbars is not desirable.

    How can I override the style of the FlexGrid horizontal and vertical scrollbars?

    Thanks,

    Felix

  • Posted 8 November 2021, 12:19 am EST

    Hi,

    The behavior of .Net 5 Flexgrid’s scrollbar is updated in 2021v3 build. However, It is not released yet. So we suggests you to use the beta build until the main build is released which is expected at the end of this month.

    Best Regards,

    Nitin

  • Posted 8 November 2021, 12:19 pm EST

    Thank you. Do you know if the new approach will allow for the styling of the scroll bar?

    Felix

  • Posted 9 November 2021, 8:19 am EST

    Hi Felix,

    You can style Scrollbars after getting it from Flexgrid’s template. You need to handle Loaded event as : (see code snippet)

    
    private void Grid_Loaded(object sender, RoutedEventArgs e)
            {
                var scrollViewer = (sender as FlexGrid).Template.FindName("ScrollViewer", sender as FlexGrid) as C1ScrollViewer;
                var verticalScrollBar = VisualTreeHelper.GetChild(scrollViewer, 5) as ScrollViewerScrollBar;
                var horizontalScrollBar = VisualTreeHelper.GetChild(scrollViewer, 4) as ScrollViewerScrollBar;
                var verticalThumb = verticalScrollBar.Track.Thumb;
                var horizontalThumb = horizontalScrollBar.Track.Thumb;
                var vRect = verticalThumb.Template.FindName("rectangle", verticalThumb) as Rectangle;
                var hRect = horizontalThumb.Template.FindName("rectangle", horizontalThumb) as Rectangle;
    
                vRect.Fill = Brushes.Black;
                hRect.Fill = Brushes.Black;
                verticalScrollBar.Track.DecreaseRepeatButton.Background = Brushes.Red;
                verticalScrollBar.Track.IncreaseRepeatButton.Background = Brushes.Red;
                horizontalScrollBar.Track.DecreaseRepeatButton.Background = Brushes.Red;
                horizontalScrollBar.Track.IncreaseRepeatButton.Background = Brushes.Red;
            }
    
    

    Please refer the attached sample for the same : FlexgridScrollbarStyling.zip

    Regards,

    Nitin

  • Posted 9 November 2021, 10:45 am EST

    Thank You.

Need extra support?

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

Learn More

Forum Channels