GdPicture.NET Reference Guide
CloseDocument Method (GdViewer)
Example 





GdPicture14.WPF Namespace > GdViewer Class : CloseDocument Method
Closes the currently displayed document and clears the GdViewer control.

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

Syntax
'Declaration
 
Public Sub CloseDocument() 
public void CloseDocument()
public procedure CloseDocument(); 
public function CloseDocument();
public: void CloseDocument(); 
public:
void CloseDocument(); 
Remarks
Just to remind you that the 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 System.Windows.Forms.FolderBrowserDialog = New System.Windows.Forms.FolderBrowserDialog()
    dialog.Description = "Select the folder you want to open your files from."
    dialog.ShowNewFolderButton = False
    dialog.RootFolder = Environment.SpecialFolder.Desktop
    If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
        Dim folder As String = dialog.SelectedPath
        Dim fileName As String = ""
        For Each fName As String In System.IO.Directory.GetFiles(folder, "*.*", System.IO.SearchOption.TopDirectoryOnly)
            If GdViewer1.DisplayFromFile(fName) = GdPictureStatus.OK Then
                Dim result As MessageBoxResult = MessageBox.Show("Next file?", "GdViewer.CloseDocument", MessageBoxButton.YesNo)
                If result = MessageBoxResult.No Then
                    fileName = fName
                    Exit For
                Else
                    GdViewer1.CloseDocument()
                End If
            End If
        Next
        'Do your stuff with fileName.
    End If
End Using
//We assume that the GdViewer1 control has been properly integrated.
using (System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog())
{
    dialog.Description = "Select the folder you want to open your files from.";
    dialog.ShowNewFolderButton = false;
    dialog.RootFolder = Environment.SpecialFolder.Desktop;
    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        string folder = dialog.SelectedPath;
        string fileName = "";
        foreach (string fName in System.IO.Directory.GetFiles(folder, "*.*", System.IO.SearchOption.TopDirectoryOnly))
        {
            if (GdViewer1.DisplayFromFile(fName) == GdPictureStatus.OK)
            {
                MessageBoxResult result = MessageBox.Show("Next file?", "GdViewer.CloseDocument", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.No)
                {
                    fileName = fName;
                    break;
                }
                else
                {
                    GdViewer1.CloseDocument();
                }
            }
        }
        //Do your stuff with fileName.
    }
}
See Also

Reference

GdViewer Class
GdViewer Members
Clear Method
Redraw Method
Dispose Method