I've been struggling to display either OK.png / NOK.png on a specific column by testing if the path of the actual PV.pdf exists ,
$dataGrid = New-Object System.Windows.Forms.DataGridView
$dataGrid.Width = 503
$dataGrid.Height = 250
$dataGrid.location = new-object system.drawing.point(120,380)
$dataGrid.DataSource = $DataTable
$dataGrid.ReadOnly = $true
$dataGrid.RowHeadersVisible = $false
$dataGrid.AllowUserToAddRows = $false
$dataGrid.AutoSizeColumnsMode = 'Fill'
$ImageColumn = New-Object System.Windows.Forms.DataGridViewImageColumn
$ImageColumn.Width = 40
$dataGrid.Columns.Insert($dataGrid.Columns.Count, $ImageColumn)
$dataGrid.Columns[$dataGrid.Columns.Count - 1].HeaderText = "PV"
$dataGrid.Columns[$dataGrid.Columns.Count - 1].Name = "ImageColumn"
$OKImage = [System.Drawing.Image]::FromFile([string]$curDir+"\images\OK.png")
$NOKImage = [System.Drawing.Image]::FromFile([string]$curDir+"\images\NOK.png")
for($i=0;$i -lt $dataGrid.RowCount;$i++) {
Write-Host $dataGrid.Rows[$i].Cells[1].Value
$dir = [string]$curDir+"\pvs\"+[string]$dataGrid.Rows[$i].Cells[1].Value+".pdf"
if ((Test-Path $dir) -eq $true) {
$dataGrid.Rows[$i].Cells[0].Value = $OKImage
} else {
$dataGrid.Rows[$i].Cells[0].Value = $NOKImage
}
}
$dataGrid.Refresh()
i get this when i run the script : Screenshot
Please help
i was expecting to display the OK.png (20x20) when the file is found and NOK.png when the file is not found .