This documentation is archived and is not being maintained.

TreeView.StateImageList Property

Gets or sets the image list used for indicating the state of the TreeView and its nodes.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public ImageList StateImageList { get; set; }

Property Value

Type: System.Windows.Forms.ImageList
The ImageList used for indicating the state of the TreeView and its nodes.

In order to indicate the state of a TreeNode, set the StateImageList property, as well as the StateImageKey or StateImageIndex property for each TreeNode.

The state images displayed in the TreeView are always 16 x 16 pixels, and setting the ImageSize property of the StateImageList will have no effect on how the images are displayed.

When the CheckBoxes property of a TreeView is set to true, and the StateImageList property is set, each TreeNode contained in the TreeView will display the first and second images from the StateImageList to indicate an unchecked or checked state, respectively. You should set the StateImageList property before adding nodes to the TreeView to prevent state images being shown at design time for nodes that do not have a state image set.

The following code example demonstrates the StateImageList property. To run this example, paste the code into a Windows Form and call InitializeCheckTreeView from the form's constructor or Load event handler.

TreeView checkTreeView;
private void InitializeCheckTreeView()
    checkTreeView = new TreeView();

    // Show check boxes for the TreeView. This 
    // will cause the StateImageList to be used.
    checkTreeView.CheckBoxes = true;

    // Create the StateImageList and add two images.
    checkTreeView.StateImageList = new ImageList();

    // Add some nodes to the TreeView and the TreeView to the form.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0