Multiple Diagrams Scrolling together
Mirroring of scrolling operation in Multiple Diagrams
The mirroring of the scrolling operation can be achieved by using the Diagram’s event sink’s OriginChanged event. It is necessary to create separate OriginChanged events for both the diagrams/views and assign the new origin reciprocally (i.e., assign the 2nd diagram’s new origin in the 1st diagram’s OriginChanged event and assign the 1st diagram’s new origin in the 2nd diagram’s OriginChanged event).
The below-attached code snippet demonstrates scrolling multiple diagrams together:
[C#]
// Initializing the OriginChanged event for both diagrams
diagram1.EventSink.OriginChanged += new ViewOriginEventHandler(Diagram1EventSink_OriginChanged);
diagram2.EventSink.OriginChanged += new ViewOriginEventHandler(Diagram2EventSink_OriginChanged);private void Diagram1EventSink_OriginChanged(ViewOriginEventArgs evtArgs)
{
// Assigning the new origin value of Diagram1 to Diagram2 while scrolling Diagram1
diagram2.View.Origin = evtArgs.NewOrigin;
diagram2.Refresh();
}private void Diagram2EventSink_OriginChanged(ViewOriginEventArgs evtArgs)
{
// Assigning the new origin value of Diagram2 to Diagram1 while scrolling Diagram2
diagram1.View.Origin = evtArgs.NewOrigin;
diagram1.Refresh();
}
[VB]
' Initializing the OriginChanged event for both diagrams
Private diagram1.EventSink.OriginChanged += New ViewOriginEventHandler(AddressOf Diagram1EventSink_OriginChanged)
Private diagram2.EventSink.OriginChanged += New ViewOriginEventHandler(AddressOf Diagram2EventSink_OriginChanged)Private Sub Diagram1EventSink_OriginChanged(ByVal evtArgs As ViewOriginEventArgs)
' Assigning the new origin value of Diagram1 to Diagram2 while scrolling Diagram1
diagram2.View.Origin = evtArgs.NewOrigin
diagram2.Refresh()
End SubPrivate Sub Diagram2EventSink_OriginChanged(ByVal evtArgs As ViewOriginEventArgs)
' Assigning the new origin value of Diagram2 to Diagram1 while scrolling Diagram2
diagram1.View.Origin = evtArgs.NewOrigin
diagram1.Refresh()
End Sub
Sample Link:
Conclusion
I hope you enjoyed learning about Multiple Diagrams Scrolling together.
You can refer to WinForms Diagram feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!