Hi All.

Hi All.
Very simple (stupid?) question.

I use a TOpenDialog with Multiselect option enabled to allow a user to select more than one file at a time: how to get (in the Files property) a list of selected filenames in the order in which the user.. selected those files? Default behavior seems to be that Files property always contains a list alphabetically reordered (first FileA, next FileB, etc.).

Thanks for your help.

Comments

  1. I think that it isn't possible, because it is a system API that returns the files in some order (as you see alphabetical)

    ReplyDelete
  2. The dialog returns the items sorted by the currently selected sort order. For example, if you open the dialog, then click on Modified column, the elements returned will be sorted by the modified time, not name.

    ReplyDelete
  3. I don't think it's meaningful to ask for a selection order. Some of the means of selecting dont have a natural order.

    ReplyDelete
  4. Even if it works, using this to order something will be much too error-prone for the user. If ordering is important, you need to provide a means for ordering after the dialog is closed.

    ReplyDelete
  5. The solution, I think, will be to create a inherited object of TOpenDialog and write there a event for mouse click on file list and also for selection by keyboard (with ctrl or else).

    ReplyDelete
  6. Have you considered using drag & drop from the explorer window instead? If the user drops files on your form one by one, you have got an order you can use. You could even display a list of dropped files so the user can change the order before accepting them.

    ReplyDelete
  7. Thomas Mueller a lot of users cannot use a mouse.

    ReplyDelete
  8. Hi all, and thanks for your help.I already had, displayed, a tlistbox with all filenames, so I decided to go for a simple ordering functionality of the names in the list, by the user. Thomas Mueller And, last but not least, I've also added drag&drop from a explorer windows, as another option for my user to get same result.

    ReplyDelete
  9. David Heffernan David, sorry for asking here, but I have a little problem with your BufferedFileStream unit (so fast code), found on StackOverflow: I don't know how to report it to you ;)

    ReplyDelete
  10. Messaging me on Hangouts would work. Or whatever the Google IM platform is called these days

    ReplyDelete
  11. Dany Marmur that might be a problem or not, depending on the intended audience.

    ReplyDelete

Post a Comment