Back to Devexpress

DiagramControl.OpenFile() Method

windowsforms-devexpress-dot-xtradiagram-dot-diagramcontrol-c1440c3f.md

latest4.6 KB
Original Source

DiagramControl.OpenFile() Method

Displays the “Open File” dialog that allows an end-user to load an XML file containing a saved diagram.

Namespace : DevExpress.XtraDiagram

Assembly : DevExpress.XtraDiagram.v25.2.dll

NuGet Package : DevExpress.Win.Diagram

Declaration

csharp
public void OpenFile()
vb
Public Sub OpenFile

Remarks

The Diagram Control’s Ribbon menu contains the “Open” button that redirects the action to the OpenFile method. By default, the standard “Open File” dialog is shown by this method. The full name of the file selected in the “Open File” dialog is automatically assigned to the DiagramControl.DocumentSource property.

The DiagramControl.ShowingOpenDialog event allows you to replace the standard “Open File” dialog with a custom one or perform your own actions when the “Open” button (in the Ribbon menu) is clicked or when the OpenFile method is directly called.

To implement diagram custom loading logic, handle the DiagramControl.CustomLoadDocument event.

To load a saved diagram to the DiagramControl in code, use the DiagramControl.DocumentSource property or DiagramControl.LoadDocument method.

You may encounter exceptions when loading/saving a diagram (e.g., when trying to load a diagram from a file that does not exist, or saving to a read-only file). To handle or suppress these exceptions, use the DiagramControl.ExceptionMessage event.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the OpenFile() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

how-to-handle-diagramcontrol-events-to-save-diagrams-to-a-database-instead-of-a-file-system-t360920/CS/XtraDiagram.CustomDiagramStorage/Form1.cs#L22

csharp
diagramControl1.InitializeRibbon(ribbonControl1);
    diagramControl1.OpenFile();
}

how-to-handle-diagramcontrol-events-to-save-diagrams-to-a-database-instead-of-a-file-system-t360920/VB/XtraDiagram.CustomDiagramStorage/Form1.vb#L19

vb
diagramControl1.InitializeRibbon(ribbonControl1)
    diagramControl1.OpenFile()
End Sub

See Also

DocumentSource

CustomSaveDocument

CustomLoadDocument

ShowingSaveDialog

ShowingOpenDialog

OpenFile()

SaveFile()

SaveFileAs()

ExceptionMessage

DiagramControl Class

DiagramControl Members

DevExpress.XtraDiagram Namespace