Reputation: 2416
I use a TOpenDialog component in Delphi XE7, because I want to select one or more files. However, after I select them and click OK, the selected files are stored already sorted alphabetically, from A to Z, in the Files property, thing which I do not want. I didn't see any switches or options neither in the TOpenDialog control, nor in the TStrings type.
How can I make this component store the selected files exactly in the order that I want to?
Upvotes: 1
Views: 892
Reputation: 163357
The underlying dialog box from the operating system doesn't keep track of that information (or if it does, it doesn't expose it in any way), and the wrapper class provided by Delphi doesn't synthesize it for you.
You can handle the OnSelectionChange
event to deduce the selection order. Begin by creating your own ordered list to hold the selected files. When the event is triggered, inspect the dialog's Files
property. Remove any entries from your internal list that aren't present in Files
. For any items in Files
that you don't already have, add them to the head of your list.
Upvotes: 3
Reputation: 613572
The system dialogs do not keep track of the order in which the items are selected. You have no way to get the system dialog to tell you that information. If you really need that then I see two options:
Upvotes: 3