FIleOpen Dialog - fileopendialog.showdialog() - Change default view from List to Details

In my app a user can mouse to File Menu - Open. The fileopendialog.showdialog() has default view of ListView. The user is alway going to have to sort the file list by Date in descending order in order to open the most recent file stored in the network location.

How can I make the FileOpenDialog display in Detail View by default and not List View.

Thanks,

MIke

Code Sample

dlgOpenFile.InitialDirectory = sDefaultDir

dlgOpenFile.FilterIndex = 0

dlgOpenFile.Filter = "All Files|*.*"

dlgOpenFile.Title = "Open PO File"

If dlgOpenFile.ShowDialog() = Windows.Forms.DialogResult.OK Then

'other code here

End IF




Answer this question

FIleOpen Dialog - fileopendialog.showdialog() - Change default view from List to Details

  • Matthew Adams9346

    This I would agree with rather than go around messing with the user settings for the folders. Changing user settings without the users knowledge is probably bad form as it often leads them to think other things are going on in there system - because there settings keep changing.

    The reason why its architected this way is the user can set the choice on how they want to see a particular folder and then whatever application they use they should see it in there choice.

    If you decide they should see it a particular way for your application then I would agree that you should code up your own custom form rather than mess with the system settings. Not ideal I know but consistent.


  • Shyne79

    Technically, the correct answer is to let the user set the folder view to details and then just go with the explorer settings.

    Windows Explorer views are one of those things that developers are not supposed to set for the user. The user should decide how they like to view their files.

    If you really wanted to force the user into a particular view at the outset, your best bet would be to just recreate the file dialog in your own custom form and then you can set your ListView object to whatever default viewstate you like.



  • Henry Hahn - MSFT

    RKimble, Thanks for seeing my objective.

    You are correct that some users may not know how to change the display settings and then sort the dialog box by date. That is exactly what we are trying to avoid, the novice user.

    We will be creating our own dialog box that will allow the user to navigate through the network shares required and select the files they need each day.



  • MariaW

    I agree to mess with a users preferences is a bad idea. I was looking for a way to change only the dialog in my app. Possibly changing the user options temporarily and the restore them to the way they were on exit.

    Looks like the path I was on and everyone like as well is to code my own dialog box

    Thanks all for the feedback, greatly appreciate the community, every one is great.



  • Benjamin00

    I guess KISS(Keep it simple (*&^^), has no meaning anymore.

    It doesn't really matter what MS or any other developer thinks is 'Broken by design' what really matters is what our users need, want and expect. We have done usabilty studies with our user base as well as extensive surveys of our employees and they do not want to have to navigate to different network shares nor to to change settings every time they need to find a file. This is a specific application that is required for our business functions. Software development isn't always about maintaining standards or developing around what someone else wants. So to save a user a few mouse clicks every once in a while (IE: Ease of use and Usabilty) is also part of our job as software developers.

    So next time a users say" Why do I always have to do this you can tell them because we felt it more important to stick with what MS says is right and decided not to make your job easier.



  • Dean Forant

    What would happen if you program crashed halfway throuhg - the settings would remain changed.

    So although its probably possible to do - its probably not a wise thing to do. Writing your own form whilst more work means that your application only determines how it appears.


  • Shona Arora

    You could set the common view state of the clients Windows explorer to view as list sorted as date descending.

  • P.J.Ganesh

    Then why are you not creating the functionality you need rather than limiting a standard function

    Rather than 'fixing' a design which isn't broken: it's not appropriate for the task you want. Stop trying to turn a 'spork' into a spoon: if you need a spoon, and will always and only need a spoon, use a spoon. You appear to have done the research into your specific needs. Build the tool for the job.



  • Gboyega

    I don't know for certain, but if you were to create a new System.IO.Directory object and link it to the folder to which the OpenFileDialog control is defaulting to, could you perhaps control the view state of the folder

    I'm just spitballing here, but I agree that the OpenFileDialog control takes it's viewing type from Explorer's pre-saved viewing types.


  • Forseti

    The whole pint of the standard dialog is so that the user has a 'standard' interface, and has full control over it to their desired view. I can't imagine a reason to 'force' a user to view such things in a specific way; it's understandable that some views are more informative than others.

    Your alternative is to build your own dialog; i'd do that before modifying any users settings. Having said that, there my be a way to get the window handle for the dialog, and the child dialog and send a message to it. But it'll need a bit of poking around with windows API calls and trial and error.



  • Jeevann

    I looked carefully and did not see a way to control that.

    My guess is that the control read the directory attributes on how that directory is to be viewed. For example, I have almost all of my directories set to details and that's what my openfiledialogy displays.

    There does not seem to be a settable propert for it



  • Desmond Molins

    Actually the whole point of the built-in dialog components is to save developers from having to code them every time. In most cases the standard Windows dialog for opening or saving a file, selecting colors or fonts, or printing work just fine. But there are many cases where the standard dialogs don't meet your needs. Many applications implement their own file browsers in order to provide some specific functionality.

    MarketFare's application here is a case in point. The user always needs to open the most recent file in a specific location, so they cannot choose the correct file without knowing it's creation date. Now let's suppose that the user doesn't even know that the standard dialog has a way to change the current view. What are they to do Forcing the ListView into a specific mode is a good idea in this case... Just becuase you can't imagine a reason for something doesn't mean that there isn't one.

    One thing that might be considered is an "Open Most Recent" button that doesn't display a dialog (or if it does, it's only a folder browser). Clicking this button would just automatically search through the files in the given location and open the one with the most current creation date. This may or may not be a logical solution based on the purpose of the application.



  • keby

    And just because the programmer thinks it'd be a great idea, doesn't mean it is...I'll reiterate - there's no reason to change the standard dialog box by taking away the users control. If you need to implement a certain functionality, then add that functionality - don't remove existing functionality.

    It's a poor excuse saying that novice users don't know how to do things (that's what a novice is), but changing a standard dialog box behavior is not doing them any favors, and is particularly shortsighted: look beyond your own application. By changing the standard behavior you confuse the user when he starts using an application which follows the standard behavior (and he'll wise up the fact that you have deliberaely limited his capability in your application).

    This is what's referred to as 'broke by design'. It may be convenient (or whimsical) to the programmer, but is not user friendly. If you need to provide a more 'user friendly' interface to achieve your needs, don't break a standard behavior, create the interface.



  • UntimelyWill

    I agree the file open/save dialog take thier view settings from the users desktop settings. I am going to experment with syste.io.directory and also possibly changing the users settings when the start the app and setting them back when they exit.

    I will respond when I have a soluiton that worked either of my own or someone else that solved it.

    Thanks



  • FIleOpen Dialog - fileopendialog.showdialog() - Change default view from List to Details