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

How to keep the view centered after zoom

Thread ID:





93768 Apr 2,2010 11:33 AM UTC Apr 13,2010 12:48 PM UTC WinForms 3
Tags: Diagram
Witold Slirz
Asked On April 2, 2010 11:33 AM UTC


After changing diagram magnification property diagram orogin is the same as it was before. So, if user click zoom in button several times, diagram view moves to the left top corner of the diagram.

But I want to keep the view centered on the same diagram poin as it was before.

There are several solutions published on this forum how to center to the selected node, but if nothing is selected things seems to be more compolicated.

How can I do this?

Melba Winshia [Syncfusion]
Replied On April 7, 2010 01:07 PM UTC

Hi Witold,

Thank you for your interest in Syncfusion Products.

You can use the following code to display the view to the center of the diagram control.

float locationX = (diagram1.Width - diagram1.View.Width) / 2;
float locationY = (diagram1.Height - diagram1.View.Height) / 2;
this.diagram1.View.Origin = new PointF(-locationX, -locationY);

Please let me know if this helps.


Witold Slirz
Replied On April 8, 2010 11:13 AM UTC

I tried, but it does not work.

ZoomIn event handler looks like this:

private void ButtonZoomPlus_Click(object sender, EventArgs e)
if (_activeDiagram != null)
_activeDiagram.View.Magnification += 25.0f;
float locationX = (_activeDiagram.Width - _activeDiagram.View.Width) / 2;
float locationY = (_activeDiagram.Height - _activeDiagram.View.Height) / 2;
this._activeDiagram.View.Origin = new PointF(-locationX, -locationY);

It seems that Diagram.View.Height and Diagram.View.Width should change values after zooming in or out, but they dont. Diagram.View.Origin is the same all the time, despite visible area became smaller after zooming. Thus, after several zoom in iterations visible area moves to the left up corner of the diagram.

Melba Winshia [Syncfusion]
Replied On April 13, 2010 12:48 PM UTC

Hi Witold,

Currently it is not possible to keep the view centered while zooming if nothing is selected. We tried for a workaround to solve this issue, but it seems to be more complicated and we are not able to achieve the accurate solution. So this has been confirmed as a Feature Request. We will implement this feature in our forthcoming new version releases or service pack releases. We usually have an interval of at least three months between releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We will get back to you once the feature is implemented.

Please let me know if you have any concerns.



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