GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / CloseDocument Method / CloseDocument() Method
Example





CloseDocument() Method
Closes the currently displayed document and clears the GdViewer control.

The GdViewer.DocumentClosed event is raised at the end after the document has been successfully closed.

Syntax
'Declaration
 
Public Overloads Sub CloseDocument() 
 
Remarks
Just to remind you that the GdViewer.DocumentClosed event is raised using this method.
Example
How to close the currently displayed document with clearing the viewer.
'We assume that the GdViewer1 control has been properly integrated.
Using dialog As FolderBrowserDialog = New FolderBrowserDialog()
    dialog.Description = "Select the folder for opening your files."
    dialog.ShowNewFolderButton = False
    dialog.RootFolder = Environment.SpecialFolder.Desktop
    If dialog.ShowDialog() = DialogResult.OK Then
        Dim folder As String = dialog.SelectedPath
        Dim fileName As String = ""
        For Each fName As String In Directory.GetFiles(folder, "*.*", SearchOption.TopDirectoryOnly)
            If GdViewer1.DisplayFromFile(fName) = GdPictureStatus.OK Then
                Dim result As DialogResult = MessageBox.Show("Next file?", "GdViewer.CloseDocument", MessageBoxButtons.YesNo)
                If result = DialogResult.No Then
                    fileName = fName
                    Exit For
                Else
                    GdViewer1.CloseDocument()
                End If
            End If
        Next
        'Do your stuff with fileName.
    End If
End Using
See Also