Datagridview search
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.
Datagridview search
Hi All,
I have a datagridview control on form. I am using below code to import a CSV:
$rows = Import-Csv .\Data.CSV -Header Data1, Data2, Data3
$table = ConvertTo-DataTable -InputObject $rows
Load-DataGridView -DataGridView $datagridview1 -Item $table
I have created a textbox and added TextChangedEvent. How can I search through datagridview? I should be able to search anywhere in Datagridview.
Thank You,
Nratawa
I have a datagridview control on form. I am using below code to import a CSV:
$rows = Import-Csv .\Data.CSV -Header Data1, Data2, Data3
$table = ConvertTo-DataTable -InputObject $rows
Load-DataGridView -DataGridView $datagridview1 -Item $table
I have created a textbox and added TextChangedEvent. How can I search through datagridview? I should be able to search anywhere in Datagridview.
Thank You,
Nratawa
- SAPIEN Support Forums
- Posts: 945
- Joined: Wed Dec 03, 2014 2:26 pm
Datagridview search
This is an automated post. A real person will respond soon.
Thank you for posting, nirmalks.
Here are some hints to help you get an accurate and complete answer to your question.
Ask in the best forum:
Anticipate follow-up questions!
Did you remember to include the following?
*** Make sure you do not post any licensing information ***
Thank you for posting, nirmalks.
Here are some hints to help you get an accurate and complete answer to your question.
Ask in the best forum:
- - Scripting question? For questions about Windows PowerShell or other scripting languages, use Scripting Answers.
- Software question? For questions about PowerShell Studio, PrimalScript, or other SAPIEN products, use Product Support Forums for Registered Customers.
- Trial question? For questions about trial versions of any SAPIEN product, use Trial Software Questions.
Anticipate follow-up questions!
Did you remember to include the following?
- 1. Product, version and build
2. 32 or 64 bit product
3. Operating system, e.g. Windows 7 64 bit.
4. Attach a screenshot, if applicable
5. Attach logs, crash reports, etc., in a ZIP file
*** Make sure you do not post any licensing information ***
Re: Datagridview search
Hello,nirmalks wrote:Hi All,
I have a datagridview control on form. I am using below code to import a CSV:
$rows = Import-Csv .\Data.CSV -Header Data1, Data2, Data3
$table = ConvertTo-DataTable -InputObject $rows
Load-DataGridView -DataGridView $datagridview1 -Item $table
I have created a textbox and added TextChangedEvent. How can I search through datagridview? I should be able to search anywhere in Datagridview.
Thank You,
Nratawa
Anyone please?
Thanks,
Nratawa
Re: Datagridview search
You can enumerate the rows and cells collections.
Re: Datagridview search
Can you please post a little example in a ForEach loop?jvierra wrote:You can enumerate the rows and cells collections.
Re: Datagridview search
Start with the help. Look closely at all examples.
help about_foreach
help about_foreach
Re: Datagridview search
Well, I'm very much aware of ForEach loop, but don't know what code to put inside it.jvierra wrote:Start with the help. Look closely at all examples.
help about_foreach
{
What Code to put in here??
}
How do I use below code in PowerShell?
if (row.Cells[row.Index].Value.ToString().Equals(searchValue))
Thanks,
Nratawa
Re: Datagridview search
PowerShell Code
Double-click the code block to select all.$datagridview.Rows | ForEach-Object{ $_.Cells| ForEach-Object{ $_.Value -eq 'SomeValue' } }
Re: Datagridview search
Great!! and thank you! you saved my day!jvierra wrote:PowerShell Code
Double-click the code block to select all.$datagridview.Rows | ForEach-Object{ $_.Cells| ForEach-Object{ $_.Value -eq 'SomeValue' } }
-Best
Re: Datagridview search
You can also do it by column if you choose the column.