Load a diagram that was created in the diagram designer in a Winform

Applies to: Nevron Diagram for .NET

How to load a diagram that was created in the diagram designer in a Winform?
  1. Drop NDrawingDocument and NDrawingView on the Form. Connect the nDrawingView1 with the nDrawingDocument1 (property Document).
  2. Open the solution explorer and make sure to add references to the following Nevron assemblies: Nevron.Diagram.dll; Nevron.Diagram.WinForm.dll; Nevron.System.dll; and Nevron.Presentation.dll;
  3. Then you can use the following code:

[C#]
using Nevron.Diagram;
using Nevron.Diagram.Extensions;
...  
// create a new persistency manager
NPersistencyManager persistencyManager = new NPersistencyManager();
  
// load a drawing from a file
NDrawingDocument drawing = persistencyManager.LoadDrawingFromFile("c:\\Temp\\FileName.ndx");
  
// display the document into the view
nDrawingView1.Document = drawing;

[VB.NET]
Imports Nevron.Diagram
Imports Nevron.Diagram.Extensions
...  
' create a new persistency manager
Dim persistencyManager As NPersistencyManager = New NPersistencyManager()
  
' load a drawing from a file
Dim drawing As NDrawingDocument = persistencyManager.LoadDrawingFromFile("c:\\Temp\\FileName.ndx")
  
' display the document into the view
NDrawingView1.Document = drawing

The FileName is the name of your Diagram Designer drawing saved in XML format. The file extension depends on the extension you have used for saving your drawing.

You can also drop NDiagramCommandBarsManager, set the nDiagramCommandBarsManager1 property View to nDrawingView1. Now you have a simple Diagramming application.

Article ID: 10, Created On: 9/28/2010, Modified: 11/15/2010