We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set ScrollBar.LargeChange on SfDataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

140797 Nov 7,2018 03:03 PM UTC Nov 14,2018 09:56 AM UTC WPF 4
loading
Tags: SfDataGrid
James Randle
Asked On November 7, 2018 03:12 PM UTC

Hi,
I have a requirement where I need to change the number of rows that are scrolled down/up when clicking on the vertical scrollbar for the SfDataGrid.

Currently, if I have, say 10 records in view, and I click the scrollbar under the slider, the SfDataGrid moves down 9 records. I want to move down 10 rows at a time so that each click shows 10 new records, rather than 9 new records and one from the previous set of records. I have tried the following code but it doesn't seem to have any effect...

        private void SfDataGrid_FilterItemsPopulated(object sender, Syncfusion.UI.Xaml.Grid.GridFilterItemsPopulatedEventArgs e)
        {
            ScrollViewer scrollViewer = sfDataGrid.GetVisualContainer().ScrollOwner;
            ScrollBar verticalScrollBar = scrollViewer.Template.FindName("PART_VerticalScrollBar", scrollViewer) as ScrollBar;
            verticalScrollBar.LargeChange = 240;
        }

Cheers,
James.

---

Just want to add that changing the value '240' to any other value makes no difference!

James Randle
Replied On November 12, 2018 10:47 AM UTC

Hi,
Any word on how to accomplish this requirement?

Cheers,
James.

Shobika Palani [Syncfusion]
Replied On November 13, 2018 11:17 AM UTC

Hi James, 

Thank you for contacting Syncfusion Support. 

We have analyzed your query to scroll multiple rows on clicking Up/Down in vertical scrollbar. You can achieve this requirement using VisualContainer.LineUp/VisualContainer.LineDown methods as like below code snippet 

private void AssociatedObject_Loaded(object sender, System.Windows.RoutedEventArgs e) 
        { 
            this.AssociatedObject.GetVisualContainer().ScrollOwner.PreviewMouseLeftButtonDown += ScrollOwner_PreviewMouseLeftButtonDown; 
        } 
 
        private void ScrollOwner_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 
        { 
            RepeatButton repeatButton = null; 
            object value = null; 
            var source = e.OriginalSource; 
            while (repeatButton == null && source != null) 
            { 
                var parent = source.GetType().GetProperty("InternalVisualParent", BindingFlags.Instance | BindingFlags.NonPublic); 
                value = parent.GetValue(source); 
                source = value; 
                repeatButton = value as RepeatButton; 
            } 
 
            if (repeatButton != null) 
            { 
                var name = ((RoutedCommand)repeatButton.Command).Name; 
                if (name == "LineUp") 
                { 
                    for (int i = 1; i < 10; i++) 
                        this.AssociatedObject.GetVisualContainer().LineUp(); 
                } 
                else if (name == "LineDown") 
                { 
                    for (int i = 1; i < 10; i++) 
                        this.AssociatedObject.GetVisualContainer().LineDown(); 
                } 
            } 
        } 

Please find sample for the same from below link 
Sample Link: 

Please let us know if you need further assistance on this. 

Regards, 
Shobika. 


James Randle
Replied On November 13, 2018 11:44 AM UTC

Hi,
Thanks for your reply.

That works if i click the up and down arrow buttons, but I would also like to have the same functionality if i click the area between the scrollbar slider and the up/down arrow buttons (see attached file for explanatory image).

Cheers,
James.



Attachment: ClickScrollbar_7dd6799f.zip

Jayaleshwari N [Syncfusion]
Replied On November 14, 2018 09:56 AM UTC

Hi James,  
 
We have checked the query “To scroll multiple rows on clicking area between Up/Down arrows in vertical scrollbar”. You can achieve your requirement by calling VisualContainer.LineUp/VisualContainer.LineDown methods for PageUp and PageDown repeat button. 
  
private void ScrollOwner_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)  
        {  
            RepeatButton repeatButton = null;  
            object value = null;  
            var source = e.OriginalSource;  
            while (repeatButton == null && source != null)  
            {  
                var parent = source.GetType().GetProperty("InternalVisualParent", BindingFlags.Instance | BindingFlags.NonPublic);  
                value = parent.GetValue(source);  
                source = value;  
                repeatButton = value as RepeatButton;  
            }  
  
            if (repeatButton != null)  
            {  
                var name = ((RoutedCommand)repeatButton.Command).Name; 
               if (name == "LineUp" || name=="PageUp") 
                { 
                    for (int i = 0; i < 10; i++) 
                        this.AssociatedObject.GetVisualContainer().LineUp(); 
                    e.Handled = true; 
                } 
                else if (name == "LineDown" || name=="PageDown") 
                { 
                    for (int i = 0; i < 10; i++) 
                        this.AssociatedObject.GetVisualContainer().LineDown(); 
                    e.Handled = true; 
                }             
   }          
}  
 
We have attached the modified sample for your reference and you can download the same from the following location. 
 
 
Please let us know if you would require further assistance. 
 
Regards,  
Jayaleshwari N. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;