Hello,
I'm trying to get data from a DatagridView that I filled with VMs info, the columns are Name, ResourceGroup, and PowerState.
How can I read the entire column Powerstate?
Thanks, best regards.
Getting Data from DataGridView Column
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: Getting Data from DataGridView Column
Tried that but the result is empty.
Attached you will find what I need to get from the grid.
Here is the code that I'm trying to get it to work.
Attached you will find what I need to get from the grid.
Here is the code that I'm trying to get it to work.
Code: Select all
foreach ($state in $datagridview1.Rows.Cells['PowerState'].Value)
{
$vm = $datagridview1.Rows.Cells['Name'].Value
$res = $datagridview1.Rows.Cells['ResourceGroupName'].Value
if ($state -eq "VM dealocated") {
start-azvm -name $vm -resourcegroup $res
} else{
$textbox.text += "´n " + "$vm is already running."
}
}
- Attachments
-
- Screenshot_1.png (22.2 KiB) Viewed 1994 times
Re: Getting Data from DataGridView Column
That is not what I posted. You have to enumerate the rows. "Cells" is not a property of the "Rows" collection. It is a property of a "row" object.
foreach ($row in $datagridview1.Rows){
foreach ($row in $datagridview1.Rows){
Re: Getting Data from DataGridView Column
Still getting null even if I use $datagridview.Cells['PowerState'].Value