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

Diagram resize

Thread ID:





100900 Sep 13,2011 10:49 AM UTC Oct 3,2011 04:19 AM UTC WinForms 5
Tags: Diagram
Domenico Mozzone
Asked On September 13, 2011 10:49 AM UTC

I'm using version
I would like to dock a Diagram control in a window showing the whole drawing area magnifying it according to the hosting window size, without vertical or horizontal grey rectangles filling the diagram control area.

I tried to use (on the Diagram.SizedChanged event) the Diagram.FitDocument() method or the Diagram.View.Magnification property reaching a poor result, not what I would like; vertical or horizontal gray rectangles are present to fill the diagram Size.

Could you kindly provide an example to obtain the required behaviour?
Best regards
Domenico Mozzone

Amsath Ali M [Syncfusion]
Replied On September 15, 2011 03:39 PM UTC

Hi Domenico,

Thanks for the update.

We suggest you to use the Diagram.Model’s ‘DocumentSize’ property to set the document size of the diagram to the screen size.

Here is the code:
int ScreenX = Screen.PrimaryScreen.Bounds.Width;
int ScreenY = Screen.PrimaryScreen.Bounds.Height;
diagram1.Size = new Size(ScreenX, ScreenY);
diagram1.Model.DocumentSize = new PageSize(ScreenX, ScreenY);

For your convenience we have created a simple sample to achieve your requirement.
Please try the below sample and let us know if you have any queries.
Forum Adding node in center-1190423141.zip

Amsath Ali. M

Domenico Mozzone
Replied On September 16, 2011 01:45 PM UTC

Hi Amsath,
thank you for your reply.

Your example is very interesting and allows to remove gray bounds, but causes the loss of zoom behaviour achieved by FitDocument() method.

I would like to resize the diagram according to hosting Form, achieving a Zoom behaviour on Nodes in the diagram, BUT without vertical gray bounds.

I updated your example adding some code to show the problem:
Add a Node from palette, and then try to resize the window -> gray bounds will fill the diagram area.
Please note that the node rezise according to Form resize is the wanted behaviour.

Thank you

Forum Adding node in center UPDATE_8c5a8f3e.zip

Amsath Ali M [Syncfusion]
Replied On September 22, 2011 04:08 AM UTC

Hi Domenico,

Thanks for the update.

The Diagram’s FitDocument method is used to fits the document based on the page size not on the control’s size. Since it fits the document only based on its document size, the gray bounds around the diagram is always visible when the diagram size is changed and this is the current behavior of the control. You can also use the diagram.View’s ‘ScrollVirtualBounds’ property to change the origin of the document when the control resized, which makes diagram looks better. Hence, we suggest you to use the previous solution provided in this forum to achieve your requirement.

Here is the code snippet:
// Gets or sets the bounds of scrollable area. Can be set only positive values.
this.diagram1.View.ScrollVirtualBounds = new RectangleF(0, 0, 0, 0);

We have modified your sample and the same can be downloaded from the below link:
Forum FitDocument-1899076960.zip

Please try the above sample and let us know if you have any queries.

Amsath Ali. M

Domenico Mozzone
Replied On September 30, 2011 01:55 PM UTC

Thanks for the reply.
Since I could not get a satisfactory behavior, I decided to use another library for this application.
Best Regards
Domenico Mozzone

Amsath Ali M [Syncfusion]
Replied On October 3, 2011 04:19 AM UTC

Hi Domenico,

Thanks for the update.

Please let us know if you require further assistance. We would be happy to help you out.

Amsath Ali. M


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

This page will automatically be redirected to the 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