Version

Change the Image of Nodes When Expanded or Collapsed

This topic will describe how to have nodes in a WinTree™ that show an image, and make that image change when the node is Expanded.

This can be done with or without an ImageList control.

  1. Add an ImageList to your form, and add at least two images to it. For the purposes of simplicity, the collapsed image will be referred to as image 0 and the expanded image will be image 1.

  2. Then, you need to attach the ImageList to the UltraTree.

To do this, select the UltraTree control on the form, and find the ImageList Property.

Drop down the list and choose the appropriate ImageList control.

  1. Go to the Load event of the Form.

  2. This code will set the image of every node in the tree. This will be the collapsed image.

In Visual Basic:

Me.UltraTree1.Override.NodeAppearance.Image = 0

In C#:

this.ultraTree1.Override.NodeAppearance.Image = 0;
  1. Next, you must apply the expanded image to the nodes. You can do this by using the ExpandedNodeAppeance of the Override .

In Visual Basic:

Me.UltraTree1.Override.ExpandedNodeAppearance.Image = 1

In C#:

this.ultraTree1.Override.ExpandedNodeAppearance.Image = 1;
  1. Run the program.

  2. All the nodes in the UltraTree will show the collapsed image by default.

  3. If any nodes are expanded, they will show the expanded image.

  4. Expand a node and the node’s image will change to the expanded image.

  5. Collapse a node and it will show the collapsed image.