Events

This article lists the events specific to all of the RadFileDialog controls.

  • PreviewClosed: This event occurs when the dialog is closing. The event arguments are of type WindowPreviewClosedEventArgs. You can use the arguments to cancel the event.

    Example 1: Cancel dialog closing

        private void FileDialog_PreviewClosed(object sender, WindowPreviewClosedEventArgs e) 
        { 
            e.Cancel = true; 
        } 
    
  • Closed: This event occurs when the dialog is closed. The event arguments are of type WindowClosedEventArgs.

  • ExceptionRaised: This event occurs when an exception is raised. This event could be raised in different occasions, for example - if the selected folder cannot be accessed or if the file path is too long, or when there is an error while searching, etc.

    Example 2: Showing an alert when an error appears

        private void openDialog_ExceptionRaised(object sender, FileBrowserExceptionRaisedEventArgs e) 
        { 
            MessageBox.Show(e.Exception.Message); 
        } 
    
  • DirectoryRequesting: This event can be used to filter the navigation RadTreeView and RadBreadcrumb or any Custom Places that are added. The following example demonstrates how you can filter out the "D:\" and "K:\" directories:

    Example 3: Filtering the D and K directories

        private void OpenFileDialog_DirectoryRequesting(object sender, Telerik.Windows.Controls.FileDialogs.DirectoryRequestingEventArgs e) 
        { 
            if (e.Directory.FullName.StartsWith("D:\\") || e.Directory.FullName.StartsWith("K:\\")) 
            { 
                e.Cancel = true; 
            } 
        } 
    

    If the InitialDirectory of the RadFileDialog is filtered out as in Example 3, the current directory on load will be the default one.

    Figure 1: Unfiltered Directories

    Figure 2: Filtered Directories Based on Example 3

  • DirectoryNavigating: This event occurs when the current folder is about to change. You can use it to execute an additional action or to cancel the navigation.

    Example 4: Disable navigation to the Program Files folder

        private void OpenFileDialog_DirectoryNavigating(object sender, Telerik.Windows.Controls.FileDialogs.DirectoryNavigatingEventArgs e) 
        { 
            if (e.DirectoryPath == "C:\\Program Files") 
            { 
                e.Cancel = true; 
            } 
        } 
    
  • ShellContextMenuOpening: This event occurs when the context menu is about to open. You can use it to cancel the menu opening or to add/remove options from the short menu (the one opened when the cursor is on an empty space in the explorer).

    Example 5: Canceling context menu opening and adding only New Folder and Paste options in the short menu

        private void OpenFileDialog_ShellContextMenuOpening(object sender, Telerik.Windows.Controls.FileDialogs.ContextMenuOpeningEventArgs e) 
        { 
            if (e.SelectedFiles.Count > 0 && e.SelectedFiles[0].Path == "C:\\Program Files") 
            { 
                e.Cancel = true; 
            } 
            else 
            { 
                e.ShortContextMenuOptions = ShortContextMenuOptions.Paste | ShortContextMenuOptions.NewFolder; 
            } 
        } 
    

See Also

In this article
Not finding the help you need? Improve this article