I appreciate your help tthus far and you have got me closer than before. This works with a single highlighted row:
$rowIndex = $ResultsDGV01.SelectedCells[0].Value
Which is great! Thank you.
But when I have multiple rows selected, $rowindex only holds the last row item selected.
Stumped, trying to get data from datagridview on click
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.
-
- Posts: 9
- Last visit: Sat Nov 04, 2023 1:54 am
-
- Posts: 9
- Last visit: Sat Nov 04, 2023 1:54 am
Re: Stumped, trying to get data from datagridview on click
I tried that and that was why I was getting the null error, when I changed it to selected row it worked. Which does what i want except it it pulls in the data for every column, I only want the data from the first row of the selected columns. I will try that again. My lack of knowledge is frustrating I'm sure, I appreciate your patience.
Re: Stumped, trying to get data from datagridview on click
The property is a collection of row objects. It must be enumerated.
https://docs.microsoft.com/en-us/dotnet ... etcore-3.1
https://docs.microsoft.com/en-us/dotnet ... etcore-3.1
-
- Posts: 9
- Last visit: Sat Nov 04, 2023 1:54 am
Re: Stumped, trying to get data from datagridview on click
Even though I made this the most convoluted post ever, I think I should post this because this works for what I want:
$rowIndex = $ResultsDGV01.SelectedRows
$rowIndex |
ForEach-Object{
$row = $_.Cells[0].value
#$ResultsDGV01.Rows.Remove($row)
}
jvierra thank you so much, I was beating my head against the wall. I super appreciate it. Now I'm going to clean up my datagrid population methods. I hope this helps at least one other person.
$rowIndex = $ResultsDGV01.SelectedRows
$rowIndex |
ForEach-Object{
$row = $_.Cells[0].value
#$ResultsDGV01.Rows.Remove($row)
}
jvierra thank you so much, I was beating my head against the wall. I super appreciate it. Now I'm going to clean up my datagrid population methods. I hope this helps at least one other person.
Re: Stumped, trying to get data from datagridview on click
Well - you are not close yet. Here is an example of how to manage a grid.
Note that if you hit the delete key you will delete a row and it will trigger a message from the event that manages deletes of data.
The code and how it works may be a bit challenging until you learn enough Pow3ershell and Forms coding to see why it works.
Note that if you hit the delete key you will delete a row and it will trigger a message from the event that manages deletes of data.
The code and how it works may be a bit challenging until you learn enough Pow3ershell and Forms coding to see why it works.
- Attachments
-
- Toolbox-Delete.psf
- (14.67 KiB) Downloaded 85 times
-
- Posts: 9
- Last visit: Sat Nov 04, 2023 1:54 am
Re: Stumped, trying to get data from datagridview on click
Sweet, thank you. And my job is in system and network management, I'm doing this as an aside learning thing. I say that as an excuse for my lack of abilities thus far. And I don't plan to quit my day job.
Re: Stumped, trying to get data from datagridview on click
No reason why you can't learn PowerShell. Just realize that it is a challenge for non-programmers until you learn the basics. Getting there takes a bit of time.
This book is a good place to start or to continue from.
https://www.sapien.com/books_training/W ... werShell-4
This book is a good place to start or to continue from.
https://www.sapien.com/books_training/W ... werShell-4
-
- Posts: 9
- Last visit: Sat Nov 04, 2023 1:54 am
Re: Stumped, trying to get data from datagridview on click
Thanks again for all your help. Good to have people like you on the internet.