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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Synchronize to grid scrolling

Thread ID:

Created:

Updated:

Platform:

Replies:

119093 May 8,2015 07:35 PM UTC May 12,2015 03:02 AM UTC WPF 1
loading
Tags: SfDataGrid
Harlan Vossos
Asked On May 8, 2015 07:35 PM UTC

I have 2 grids on a window.   When I scroll a grid I want to programmatically scroll the second one.   Both grids have the same number of columns/rows....  Basically how to keep them showing the same row/column?

Muthalagu M [Syncfusion]
Replied On May 12, 2015 03:02 AM UTC

Hi Harlan,

Thank you for using Syncfusion Products.

We have analysed your query and you can achieve your requirement with the help of VisualContainer in SfDataGrid. We have prepared the sample also and you can download the sample from the following location,

Sample: ScrollingTwoGridAtSameTime.zip


In this sample, we have used the same number of row and column count in two grids. With the help of VisualContainer in both the grids, we have accessed the internal ScrollViewer and scroll the grids based on their offset value in ScrollChanged event of ScrollViewer. Please find the code snippet below,

//ScrollChanged event of ScrollViewer in Datagrid1

void ScrollOwner1_ScrollChanged(object sender, ScrollChangedEventArgs e)

{

if (e.HorizontalChange > 0 || e.HorizontalChange < 0)

{

this.Datagrid1.GetVisualContainer().SetHorizontalOffset(e.HorizontalOffset);

this.Datagrid2.GetVisualContainer().SetHorizontalOffset(e.HorizontalOffset);

}


if (e.VerticalChange > 0 || e.VerticalChange < 0)

{

this.Datagrid1.GetVisualContainer().SetVerticalOffset(e.VerticalOffset);

this.Datagrid2.GetVisualContainer().SetVerticalOffset(e.VerticalOffset);

}

}


//ScrollChanged event of ScrollViewer in Datagrid2

void ScrollOwner2_ScrollChanged(object sender, ScrollChangedEventArgs e)

{

if (e.HorizontalChange > 0 || e.HorizontalChange < 0)

{

this.Datagrid1.GetVisualContainer().SetHorizontalOffset(e.HorizontalOffset);

this.Datagrid2.GetVisualContainer().SetHorizontalOffset(e.HorizontalOffset);

}

if (e.VerticalChange > 0 || e.VerticalChange < 0)

{

this.Datagrid1.GetVisualContainer().SetVerticalOffset(e.VerticalOffset);

this.Datagrid2.GetVisualContainer().SetVerticalOffset(e.VerticalOffset);

}

}


Please let us know in case of any other queries.

Regards,
Muthalagu

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.

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

;