Skip to content

Latest commit

 

History

History
71 lines (58 loc) · 1.98 KB

kb-cloudupload-howto-show-radfileopendialog.md

File metadata and controls

71 lines (58 loc) · 1.98 KB
title description type page_title slug position tags res_type
Open a RadOpenFileDialog when Using the RadCloudUpload
Replace the Default OpenFileDialog when Browsing Files.
how-to
Use a RadOpenFileDialog to Select the Files to be Uploaded
kb-cloudupload-howto-show-radfileopendialog
0
cloudupload, replace, openfiledialog
kb

Environment

Product RadCloudUpload for WPF

Description

How to replace the default MS OpenFileDialog with a [RadOpenFileDialog]({%slug radfiledialogs-radopenfiledialog%}).

Solution

Handle the AddingFiles event of the RadCloudUpload control, cancel the creation of the default dialog with the CancelDialogOpening property, open a new RadOpenFileDialog and populate the FileNames collection with the files, selected in the dialog.

[C#]

{{region cs-kb-cloudupload-howto-show-radfileopendialog-1}} private void RadCloudUpload_AddingFiles(object sender, AddingFilesEventArgs e) { e.CancelDialogOpening = true;

    if (fileDialog == null)
    {
        fileDialog = new RadOpenFileDialog();
        fileDialog.Multiselect = true;
    }

    if (fileDialog.ShowDialog() == true)
    {
        foreach (var file in fileDialog.FileNames)
        {
            e.FileNames.Add(file);
        }
    }
}

{{endregion}}

[VB.NET]

{{region vb-kb-cloudupload-howto-show-radfileopendialog-1}} Private Sub RadCloudUpload_AddingFiles(ByVal sender As Object, ByVal e As AddingFilesEventArgs) e.CancelDialogOpening = True

	If fileDialog Is Nothing Then
		fileDialog = New RadOpenFileDialog()
		fileDialog.Multiselect = True
	End If

	If fileDialog.ShowDialog() = True Then
		For Each file In fileDialog.FileNames
			e.FileNames.Add(file)
		Next file
	End If
End Sub

{{endregion}}

See Also

  • [RadCloudUpload Eventts]({%slug radcloudupload-features-events%})
  • [RadOpenFileDialog]({%slug radfiledialogs-radopenfiledialog%})