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





In This Topic
CloseDocument() Method
In This Topic
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 Overloads 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 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
//We assume that the GdViewer1 control has been properly integrated.
using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{
    dialog.Description = "Select the folder for opening your files.";
    dialog.ShowNewFolderButton = false;
    dialog.RootFolder = Environment.SpecialFolder.Desktop;
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        string folder = dialog.SelectedPath;
        string fileName = "";
        foreach (string fName in Directory.GetFiles(folder, "*.*", SearchOption.TopDirectoryOnly))
        {
            if (GdViewer1.DisplayFromFile(fName) == GdPictureStatus.OK)
            {
                DialogResult result = MessageBox.Show("Next file?", "GdViewer.CloseDocument", MessageBoxButtons.YesNo);
                if (result == DialogResult.No)
                {
                    fileName = fName;
                    break;
                }
                else
                {
                    GdViewer1.CloseDocument();
                }
            }
        }
        //Do your stuff with fileName.
    }
}
See Also