5

enter image description hereI am having difficulty in customizing OpenFileDialog box, I want to allow people to select files that are in the same directory from the currently open folders using the OpenFileDialog. I don't want the OpenFileDialog to be able to select stuff outside of the program's current directory

Due to some reason i am not able to post image, what i meant is to lock Top navigation and Side Navigation option in OpenFileDialog box

  • 2
    You can't. Use the FileOk event to whack the user's knuckles with a ruler. – Hans Passant Nov 23 '12 at 17:12
  • 2
    I think Hans is right. Even if you disable navigation, a user could still type in a full path. You may have to simply check the path returned and then display an error message if the user selected something invalid. – Jon B Nov 23 '12 at 19:25

3 Answers3

1

As far as I know you can only add elements to the standard file dialogs (using some esoteric api calls), but there is no way to remove elements. Your best bet, if you really need this functionality, is to implement your own custom Open File Dialog with the specific business rules you need.

Here are some details on how to do some limited customizations.

http://msdn.microsoft.com/en-us/magazine/cc300434.aspx

http://www.codeproject.com/Articles/16276/Customizing-OpenFileDialog-in-NET

Customizing OpenFileDialog

Community
  • 1
  • 1
Bradley Uffner
  • 16,641
  • 3
  • 39
  • 76
0

Customizing a default dialog might be the hard way to go.

Why not just show a listbox containing the names of the files you wish the user to be able to select?

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
0

I don't know how to lock the dialog. But if the requirement is simply to present a list of files from which they select one. Then why not just read the file list yourself and present them in a custom dialog for selection?

If you want you can then spend some time making the dialog look like the system one.

Preet Sangha
  • 64,563
  • 18
  • 145
  • 216