ImageList
In a ScriptoForm, the ImageList the Microsoft .NET class is a component used to manage a collection of Image objects. An ImageList is typically used by other controls, such as the ListView, TreeView, or ToolBar. You can add bitmaps or icons to the ImageList, and the other controls are able to use the images as they require.
- Instantiate a new
System.Windows.Forms.ImageListobject in the Controls region. - Set
TransparentColor,ColorDepth, andImageSizeproperties to the ImageList object (and/or other properties as needed) in the$ShowFormMainscript block in the Forms region. - Add images to
ImageList.ImageCollectionproperty of the ImageList object as needed. This might be peformed initially, in the$ShowFormMainscript block in the Forms region, or within an Event Handler script block. - Assign the ImageList component to a control, such as a ListView, in the
$ShowFormMainscript block in the Forms region.
Examples
Section titled “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 = $ImageListMainThe above example shows how to use an ImageList component to store images for use by a ListView control.