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 forum is a space to discuss coding involving Graphical User Interfaces (GUI) in PowerShell or using WinForms controls, and technical issues related to development.
This topic is 2 years and 2 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 am using an edit box to filter strings I have populated in a single column gridview. It works - and I love it, but its slow.
Based on the code I'm using which I believe I found elsewhere here - is there a way to make it run faster? I am pulling in a list of GPO's, and there are probably 500 items...
You ignored the most basic issue. Use a DataTable and filter that. Your code is not very good, and I do not know of any programmer that would try to code a filter like that. A Listbox can be data bound to a DataTable object and the table object can be directly filters.
I recommend learning a bit about PowerShell beyond just old batch or Basic language methods. Remember that you are using and advanced hi-tech coding system. Old ideas won't work well, and things get worse when you apply that to WinForms.
Here is a PSF with a demo of how to use data bound listboxes. Two files. Put both in the same folder.
Yes. Use a DataBound Listbox and filter the underlying DataTable. It takes only one line of code to do that, and it is almost instantaneous for less than a thousand strings.
Another simple method if you have a small number of rows is disable updates before the loop and re-enable them after the loop. In a loop each time you make a row hidden the whole DGV will be redrawn. That may be the most time consuming issue.
To disable layout updates: $form1.SuspendLayout()
To re-enable layout updates: $form1.ResumeLayout()
welp.. I did give it a go converting my initial "textchanged" input box event to work on a listbox - the issue I had there was the "visible" property is not valid for a listbox.
So I'm assuming simply reverse engineering what I'm using right now isn't going to work with a listbox.
Any further pointers, or even a spoiler would be delightful.
You ignored the most basic issue. Use a DataTable and filter that. Your code is not very good, and I do not know of any programmer that would try to code a filter like that. A Listbox can be data bound to a DataTable object and the table object can be directly filters.
I recommend learning a bit about PowerShell beyond just old batch or Basic language methods. Remember that you are using and advanced hi-tech coding system. Old ideas won't work well, and things get worse when you apply that to WinForms.
Here is a PSF with a demo of how to use data bound listboxes. Two files. Put both in the same folder.
Oh I do not disagree with anything you said. Its been about a 31 year long learning process but with very little time to dedicate to it because I'm tasked with so many other duties. And yes, I did misunderstand your initial reply - the second one got through my head a bit better.
This topic is 2 years and 2 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.