我正在編寫一個xml gui閱讀器,只是爲了好玩,但我在如何用數據填充listview時遇到了一些問題。PowerShell GUI - 無法在GUI中正確加載的數據
當我運行PowerShell腳本:img1
錯誤的樣子,當我點擊搜索按鈕: img2
左邊屏幕上的數據是正確的,但它應該在ListView上傳,當我點擊搜索按鈕。
查詢:
$GetXmlFileNames = Get-ChildItem -Path $ApplicationFormTextboxUncPath -Recurse -force -Include $ApplicationFormButtonSearchFileTypes | Select-String -Pattern $Pattern | Format-List Filename, Path | Out-String
ForEach ($Object in $GetXmlFileNames){
Write-Host $GetXmlFileNames
% {
if ($XML.Options.FileInfo.FileName.Enabled -eq $True) {
Foreach-Object {
# Populate the XML columns with data
# Start Color
$SItem = New-Object System.Windows.Forms.ListViewItem(" Start - File Attribute ")
$SItem.BackColor = "Black"
$SItem.ForeColor = "White"
$LvMain.Items.Add($SItem)
# Xml File
$Item = New-Object System.Windows.Forms.ListViewItem(" Xml - FileName :")
$Item.SubItems.Add($_.Filename) }
$LvMain.Items.Add($Item)
#Xml DirectoryName
$Item = New-Object System.Windows.Forms.ListViewItem(" Xml - DirectoryName :")
$Item.SubItems.Add($_.Path) }
$LvMain.Items.Add($Item)
$EItem = New-Object System.Windows.Forms.ListViewItem(" End - File Attribute ")
$EItem.BackColor = "Red"
$EItem.ForeColor = "Black"
$LvMain.Items.Add($EItem)
}
項目:https://github.com/fardinbarashi/Powershell-XmlPatternLookUp
詩代碼 :https://github.com/fardinbarashi/Powershell-XmlPatternLookUp/blob/master/labxml.ps1
現在,我的想法是,你在IMG2看到文件名和路徑,應在加載列表視圖(LvMain)
我該怎麼做?
我通過將數據導出到csv文件然後填充它來解決它。 它的選擇字符串,我認爲是搞砸了 –
好吧,很高興知道。有意思的Gridview會更有意義,因爲它涉及一個圖形,儘管如此,歡呼雀躍 – trebleCode