Either I have a very senior moment or filtering in an OpenDialog doesn’t work anymore at all. Using the following code:
Dim dlg As New OpenDialog
dlg.Title = "Select a Text file"
dim t as new FileType
t.Extensions = "txt"
dlg.Filter = t.Extensions
Dim f As FolderItem = dlg.ShowModal
beep
in 2016r3 and beyond shows every file as selectable. Tried with a pre-defined filetype and with setting the Filter to “txt”. No dice.
Any ideas?
Dim txtType As New FileType
txtType.Name = "Text/txt"
txtType.MacType = "TXT "
txtType.Extensions = "txt"
dlg.Filter = txtType
Thanks, Axel, was missing the name.
Do we really need to still use MacType?
I found lately that creating (temporary) File Type Set in the code I need it filter, really filter file types
On the other hand, I never was able to ser an Icon (rethorical question).
from FileType.Icon
This is a read-only property. You can only specify an icon using the File Types Set Editor.
Thanks Axel.
Argh ! I do it again: I read the first sentence and forgot the second.
But, it is a bit stupid to put a Property and do not be able to use it. (or I miss something else).
You also need to be aware that this method of filtering file types doesn’t work as of 2016r3:
dlg.Filter=FileTypes1.myfiletype
This is a bug (#45392 ) that’s been verified, but not fixed. For the foreseeable future, don’t rely on it.
A workaround is to use this instead:
dlg.Filter=FileTypes1.myfiletype.Extensions
@John McKernon:
dlg.Filter=FileTypes1.myfiletype.Extensions
also doesn’t work anymore in 2016r3.
That is also noted in the bug report
I’d forgotten that part, fortunately Tim’s workaround works. Still, this should get fixed.
Norman_P
(Norman P)
November 19, 2016, 10:08pm
13
Yes it should
I’ve been looking into it
I’m not sure but it seems this bug has been resolved in previous version but I have it in Xojo 2017 r2.1 .