Zoom to fit in diagram view

Hello,

I'm trying to add a Zoom to fit feature to my diagram control view.

I tried this:
diagram.View.FitDocument();
It did not work.
Is there an easy way to do it ?

Regards,
Lotfi



4 Replies

AM Ajeet M Syncfusion Team January 27, 2009 07:40 AM UTC

Hi Lofti,

You can use the following code snippet:

this.diagram1.FitDocument();

Let me know if this helps.

Happy Coding!
- Ajeet




LB Lotfi Belattar January 27, 2009 10:36 PM UTC

Thank's Ajeet! That works!



LB Lotfi Belattar February 4, 2009 11:07 PM UTC

Hello Ajeet,

I need to remove the size to content (this.diagram1.Model.SizeToContent = false) in my application in order to create a diagram without bounding for my nodes.
By doing this, the FitDocument (this.diagram1.FitDocument() )is not working properly.
Is there another way to fit my nodes in my view ?

Thanks
Lotfi




AM Ajeet M Syncfusion Team February 5, 2009 09:56 AM UTC

Hi Lotfi,

The FitToDocument() is used to fit the entire diagram to your view area.

The SizeToContent = true keeps the bounds flexible, ensuring that all the nodes on the model are accommodated easily.

When the SizeToContent = false, is set, it becomes our responsibility to ensure that all the nodes are inside the bounds of the model.

Thus, I would suggest you to manually set the model's logical size to a size you feel, will accommodate all the nodes perfectly.

Let me know if you shall need any further clarifications in this regard.

Happy Coding!
- Ajeet



Loader.
Up arrow icon