Exclude files from being displayed in a FileView control
Posted
#1
(In Topic #678)
Trainee
Thanks,
bazzvn
Posted
Regular

Code (gambas)
- ' Gambas class file
- DirBox1.Value = "/home/hans/BildTon" ' (Start-)Folder
- FileView1.IconSize = 32 ' Default-Value = 32
- FileView1.Background = &HC3DDFF
- FileView1.Foreground = Color.DarkGreen
- 'Note this is where you setup what files you wish to display.
- 'All others will not be show in the FileView.
- FileView1.Filter = ["*.txt", "*.png", "*.pd*", "*.jp*", "*.xml"]
- sFileName = FileView1.Current
- sFileDir = FileView1.Dir
- sFilePath = sFileDir &/ sFileName
- btnSetMultiple.Caption = "Set file selection to single"
- btnSetMultiple.Caption = "Set file selection to multiple"
- lblFileName.Text = ""
- aFileNames = FileView1.Selection
- sContent &= sFile & gb.Lf
- FileView1.UnselectAll()
- btnSetMultiple.Caption = "Set file selection to multiple"
This is a lot of good information with Gambas-Buch at this website.
https://www.gambas-buch.de/doku.php
Hope this helps.
Posted
Regular

bazzvn said
… I specifically want to display all files in a directory EXCEPT "*.html" and "*.txt" files…
I would have expected to use something like this;
Code (gambas)
- FileView1.Filter = ["^.txt,^.html, Most Files"]
…but I can't get it to work. Sorry.
Posted
Regular

I try to filter, but not successbazzvn said
I specifically want to display all files in a directory EXCEPT "*.html" and "*.txt" files
maybe altering the class FileView.class adding
Regards.
Posted
Guru

[EDITED]
Code (gambas)
- FileView1.Filter = ["*[^\{.html}][^\{.txt}]"]
Also this…
Code (gambas)
- FileView1.Filter = ["*[^\{.html,.txt}]"]
FileView uses gambas LIKE command so read here…
/lang/like - Gambas Documentation
Posted
Regular

BruceSteers said
does this work…
[EDITED]
Ok, i was checking the previous proposal and there are some errors. This version works perfect !
it was…
Code (gambas)
- FileView1.Filter = ["*[^.csv][^.txt]"]
</IMG>But now
Code (gambas)
- FileView1.Filter = ["*[^\{.csv},\{.txt}]"]
</IMG>
Posted
Guru

tincho said
BruceSteers said
does this work…
[EDITED]
Ok, i was checking the previous proposal and there are some errors. This version works perfect !
it was…But nowCode (gambas)
FileView1.Filter = ["*[^.csv][^.txt]"]Code (gambas)
FileView1.Filter = ["*[^\{.csv},\{.txt}]"]
yes i realised after reading the LIKE wiki that it needed the {curly braces}
i think you use too many in your different copy of mine.
Code (gambas)
- FileView1.Filter = ["*[^\{.csv,.txt}]"]
Posted
Guru

Posted
Guru

- <LI>FileView1.Filter = ["*[^{.html,.txt}]"]</LI>
<LIST>
- <LI>FileView1.Filter = ["*[^{.html}][^{.txt}]"]</LI>
<LIST>
- <LI>FileView1.Filter = ["*[^{*.html,*.txt}]"]</LI>
I have done a little testing and found that all the proposed Filters above will hide .odt files as well, I'm not sure why.
Posted
Regular

Filter it because .txt has the letter "t" and .odt also, which indicates that something is not right in this way of filtering.cogier said
I have done a little testing and found that all the proposed Filters above will hide .odt files as well, I'm not sure why.
I checked by changing .txt to .csv and in that case the .odt file is not filtered.
It also does not work properly when there are uppercase extensions.
Regards.
Posted
Trainee
Perhaps this is not such a simple question as originally thought. It will be a week or so before I have time to follow up.
Thanks again,
bazzvn
1 guest and 0 members have just viewed this.


