I have a winform application which populate some data after I click on $button_UpdateTS
, how do I add the data stored in a variable, that comes available after I click on that button ?
The data I want in my list view is stored in an array called $results
$button_UpdateTS = New-Object System.Windows.Forms.Button
$button_UpdateTS.Location = New-Object System.Drawing.Size(15, 954)
$button_UpdateTS.Size = New-Object System.Drawing.Size(320, 32)
$button_UpdateTS.TextAlign = "MiddleCenter"
$button_UpdateTS.Text = “Update Tasksequence”
$button_UpdateTS.Add_Click( { $Results = Set-DynamicVariables
-Manufacturer "$($listview_Vendor.SelectedItems)"
-TSPackageID "$($ListView_Tasksequences.SelectedItems.SubItems[1].Text)" -WhatIf })
$Form.Controls.Add($button_UpdateTS)
Which gives me :
$Results =
SKUNotExistsDriverName : XPS Notebook 9560
SKUNotExistsDriverID : PS10053F
SKUNotExistsDriverSKU : 07BE
SKUNotExistsDriverVersion : A12
SKUNotExistsBIOSName : XPS Notebook 9560
SKUNotExistsBIOSID : PS10053E
SKUNotExistsBIOSSKU : 07BE
SKUNotExistsBIOSVersion : 1.15.0
This is the list I want it stored in :
$Global:listview_NotExists_SKU = New-Object System.Windows.Forms.ListView
$listview_NotExists_SKU.Location = New-Object System.Drawing.Size(515, 670)
$listview_NotExists_SKU.Size = New-Object System.Drawing.Size(486, 235)
$listview_NotExists_SKU.View = "Details"
$listview_NotExists_SKU.FullRowSelect = $true
$listview_NotExists_SKU.MultiSelect = $true
$listview_NotExists_SKU.Sorting = "None"
$listview_NotExists_SKU.AllowColumnReorder = $true
$listview_NotExists_SKU.GridLines = $true
$listview_NotExists_SKU.Add_ColumnClick( { SortListView $this $_.Column })
$Form.Controls.Add($listview_NotExists_SKU)
I tried with this function, but that does not work:
Function Get-Results {
ForEach ($Result in $Results) {
$listview_NotExists_SKU.Items.Add($Result)
}
}
$Form.Add_Shown( { $Form.Load; Get-results })
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…