Skip to content

ImageList Component

In a ScriptoForm, an ImageList component is used to manage a collection of Image objects. An ImageList is typically used by other controls, such as the ListViewTreeView, or ToolBar. You can add bitmaps or icons to the ImageList, and the other controls are able to use the images as they require.

Examples

# Create the ImageList and assign properties:
$ImageListMain = New-Object -TypeName System.Windows.Forms.ImageList
$ImageListMain.TransparentColor = [Drawing.Color]::Transparent
$ImageListMain.ColorDepth = [System.Windows.Forms.ColorDepth]::Depth32Bit
$ImageListMain.ImageSize = New-Object -TypeName System.Drawing.Size(32,32)

# Add files to the ImageList:
$ImageListMain.Images.Add([Drawing.Image]::FromFile($ToolPNGFile))
$ImageListMain.Images.Add([Drawing.Image]::FromFile($ScriptICOFile))
foreach ($IconFile in Get-ChildItem $CustomIconsLocation)
{ 
    $ImageListMain.Images.Add($IconFile.BaseName,[System.Drawing.Icon]::ExtractAssociatedIcon($IconFile.FullName))
}

# Assign the ImageList to a control:
$ListViewMain.LargeImageList = $ImageListMain

Notes

The above code example shows how to use an ImageList component to store images for use by a ListView control.

References

ImageList Class (System.Windows.Forms) | Microsoft Learn