This documentation is archived and is not being maintained.

TreeView.StateImageList Property

Note: This property is new in the .NET Framework version 2.0.

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 */
public ImageList get_StateImageList ()

/** @property */
public void set_StateImageList (ImageList value)

public function get StateImageList () : ImageList

public function set StateImageList (value : ImageList)

Property Value

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();
    checkTreeView.StateImageList.Images.Add(SystemIcons.Question);
    checkTreeView.StateImageList.Images.Add(SystemIcons.Exclamation);
    
    // Add some nodes to the TreeView and the TreeView to the form.
    checkTreeView.Nodes.Add("Node1");
    checkTreeView.Nodes.Add("Node2");
    this.Controls.Add(checkTreeView);
}

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0
Show: