Product, version and build:
Powershell Studio 2017 version:5.4.140
64 bit version
Operating system: Windows 7
64 bit OS
PowerShell Version: 5
---------------------------------------
Hi,
I am using the built-in Winform Template Full Grid Search Template. It works but what I need it to do is when I search only show in the grid what I am searching for not just take me to the place in grid where the item I am searching is. How and where should I make that change.
Grid search output
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.
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.
Re: Grid search output
Can you please give me an example. There are a lot of premade functions. I understand some of it but not all. I tried the below
- $formMain_Load= {
- $UsersComputers = import-csv Computer.csv
- $importData = $UsersComputers | sort-object -Property IPAddress, ComputerName, Username, LastBootTime, City, SoftwareName, SoftwareVersion -Unique
- $table = ConvertTo-DataTable -InputObject $importData -FilterWMIProperties
- Update-DataGridView -DataGridView $datagridviewResults -Item $table -AutoSizeColumns DisplayedCells
- }
- $buttonSearch_Click={
- $SearchTable = SearchGrid
- $table = ConvertTo-DataTable -InputObject $SearchTable -FilterWMIProperties
- Update-DataGridView -DataGridView $datagridviewResults -Item $table -AutoSizeColumns DisplayedCells
- }
Re: Grid search output
In the search grifd form the grid is already bound to a table so just use the "RowFilter" to return the rows wanted.
Example:
Example:
- $textboxSearch_KeyUp=[System.Windows.Forms.KeyEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.KeyEventArgs]
- if($_.KeyCode -eq 'Enter' -and $buttonSearch.Enabled){
- if($textboxSearch.Text){
- $datagridviewResults.DataSource.DefaultView.RowFilter = "ProcessName LIKE '*$($textboxSearch.Text)*'"
- }
- $_.SuppressKeyPress = $true
- }
- }
Re: Grid search output
How does this re-populate the datagrid with what I searched for in the text box. I am trying to understand how to re populate the grid with what is in the search box and only.
Re: Grid search output
I see what you are saying now. Last question. How can I filter off of multiple columns. I tried the below.
- if($_.KeyCode -eq 'Enter' -and $buttonSearch.Enabled)
- {
- if ($textboxSearch.Text)
- {
- ($datagridviewResults.DataSource.DefaultView.RowFilter = "ProcessName LIKE '*$($textboxSearch.Text)*'") -or
- ($datagridviewResults.DataSource.DefaultView.RowFilter = "SoftwareName LIKE '*$($textboxSearch.Text)*'")
- }
- }