datagridview cell reading

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 8 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
FSU-Systems
Posts: 8
Last visit: Wed Oct 27, 2021 7:53 am

Re: datagridview cell reading

Post by FSU-Systems »

Seems my attachment did not go last time.

Think I may be missing something, you are talking about the names of the columns, am I correct that is what I am specifying in the following pictures
ColumnName-Header.PNG
ColumnName-Header.PNG (8.05 KiB) Viewed 1658 times
For that one the

Column Name = ColUser
Column Header = Username
ColumnName-Header2.PNG
ColumnName-Header2.PNG (7.62 KiB) Viewed 1658 times
Column Name = ColPool
Column Header = Pool ID

All Columns
AllColumns.PNG
AllColumns.PNG (25.8 KiB) Viewed 1658 times

With this, I still get blank white space when using either

Write-Host $row.Cells['ColUser'].Value
Write-Host $row.Cells['Column1'].Value

I also tried changing it to a string to see if maybe it was the formatting of the cell, but no luck just whitespace still

Seems like the Write-Host is trying to do something, but no output.

Thanks
User avatar
FSU-Systems
Posts: 8
Last visit: Wed Oct 27, 2021 7:53 am

Re: datagridview cell reading

Post by FSU-Systems »

One update on that, I found in the Properties section of the Columns that it does show the Name there and appears to be what I set to
ColUser.PNG
ColUser.PNG (13.29 KiB) Viewed 1658 times
User avatar
FSU-Systems
Posts: 8
Last visit: Wed Oct 27, 2021 7:53 am

Re: datagridview cell reading

Post by FSU-Systems »

Think I found a working solution. Instead of looking at the Cell Name with

$row.Cells['ColUser'].Value

I used

$UserN = $row.cells[0].Value

And got the Data from the Cell

Thanks for all the assistance
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: datagridview cell reading

Post by jvierra »

It works fine for me. Here is an example:
Attachments
Demo-DGVExport3.psf
(20.5 KiB) Downloaded 99 times
This topic is 6 years and 8 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