Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
I have a list box that goes to a path and shows all files in the path. I want to hide a certain file from being seen in the list box GUI. Is there a way to hide from view. I am still using the file in the code. Please see the code below I am using load the list of files into the GUI.
When you use 'get-childitem', you'll have the file "extention" property available. This way you can narrow the selection to be listed.
Of course, it's possible to use both the '-filter' parameter or use the "... | where-object{.." to narrow the files.
I am getting the error below. I thought using a star and the ext I wanted would fix the issue since I am using gci in the Load-FileList function. But it is giving the below error
ERROR: Load-FileList : Cannot process argument transformation on parameter 'FileListFolder'. Cannot convert value "C:\allFiles\*.txt" to
ERROR: type "System.IO.DirectoryInfo". Error: "Illegal characters in path."
APP.psf (3, 34): ERROR: At Line: 3 char: 34
ERROR: + ... -FileList -FileListFolder "C:\allFiles\*.txt"
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidData: (:) [Load-FileList ], ParameterBindingArgumentTransformationException
ERROR: + FullyQualifiedErrorId : ParameterArgumentTransformationError,Load-FileList
ERROR:
If you need to selectively show and hide or selectively show files in a listbox or other data bound controls then you can just set the filter on the datatable the control is bound to. This saves requerying for data. The datatable has a defaultview with a "RowFilter" property that can be set to filter the visible rows:
Note that "SuspendLayout" is used to control flicker on slow processors. Using a table to load a list box does not cause flicker on nearly all modern systems. Using "Add" to load a very large ListBox may cause some small amount of flicker. I recommend not using it and not using "Add" when not needed. Use an object data source or table.
This topic is 6 years and 6 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.