Querying DataGridView

Ask your PowerShell-related questions, including questions on cmdlet development!
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 7 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.
Locked
User avatar
supportMIB
Posts: 62
Last visit: Thu Feb 29, 2024 11:17 am

Querying DataGridView

Post by supportMIB »

I have a datagrid view that is populated with:

Code: Select all

$Global:coll = (Get-ADUser -filter * -Properties PasswordNeverExpires, passwordlastset, lastlogon, enabled | select Name, Enabled, PasswordNeverExpires, PasswordLastset, @{ name = "LastLogon"; Expression = ({ get-date $_.lastlogon -UFormat "%D %R" }) })

Update-DataGridView $datagridview6 $coll
This populates it with all of our AD users, with their username, enabled status etc...

I have a group box that contains several checkboxes such as:
[ ] Non-Expiring Accounts (this would slim the datagridview to just showing non-expiring accounts)
[ ] Older than 90 days (this would display accounts older than 90 days)
etc

My issue with this is when I click Non expiring password box, it slims down the list to only show those, but what if i wanted to see non expiring AND older than 90 days?

What is the best way to achieve this?

Should I have it show non expiring, then re-query the orignal data (stored in $coll) and add that to the datagridview then remove duplicates?

Any suggestions would be appreciated
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Querying DataGridView

Post by jvierra »

To filter on multiple criteria you will need to use a DataTable and set the "RowFilter" property of the "DefaultDataView". Use your search engine to find examples of using the "DefaultDataView.RowFilter" property.
This topic is 6 years and 7 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.
Locked