GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / CloseDocument Method / CloseDocument(Boolean) Method
Specifies whether the control will clear or not after closing the document. Set this parameter to true, if you do not want to clear the control, otherwise set it to false.
Example





In This Topic
CloseDocument(Boolean) Method
In This Topic
Closes the currently displayed document in the GdViewer control. At the same time, you can specify, if the control will subsequently clear or not.

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

Syntax
'Declaration
 
Public Overloads Sub CloseDocument( _
   ByVal NoCLear As Boolean _
) 
public void CloseDocument( 
   bool NoCLear
)
public procedure CloseDocument( 
    NoCLear: Boolean
); 
public function CloseDocument( 
   NoCLear : boolean
);
public: void CloseDocument( 
   bool NoCLear
) 
public:
void CloseDocument( 
   bool NoCLear
) 

Parameters

NoCLear
Specifies whether the control will clear or not after closing the document. Set this parameter to true, if you do not want to clear the control, otherwise set it to false.
Remarks
Just to remind you that the DocumentClosed event is raised using this method.
Example
How to close the currently displayed document with or without 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
                    'The viewer will not clear after closing the document.
                    GdViewer1.CloseDocument(true)
                    Exit For
                Else
                    'The viewer will clear after closing the document.
                    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;
                    //The viewer will not clear after closing the document.
                    GdViewer1.CloseDocument(true);
                    break;
                }
                else
                {
                    //The viewer will clear after closing the document.
                    GdViewer1.CloseDocument();
                }
            }
        }
        //Do your stuff with fileName.
    }
}
See Also