Skip to main content
A newer version of this page is available. .
Tab

TreeViewNode.Image Property

Gets the settings of a node’s image.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v19.1.dll

Declaration

public ItemImageProperties Image { get; }

Property Value

Type Description
ItemImageProperties

A ItemImageProperties object that contains image settings.

Remarks

The Image property provides access to the settings that define an image displayed within the node. The specified image can be used as a link if the ASPxTreeView.NodeLinkMode property is set to the TextAndImage or ContentBounds value.

In order to assign the same image to all nodes within an ASPxTreeView, the TreeViewImages.NodeImage can be used.

Example

The code below demonstrates how you can define node images and change them, when expanding and collapsing nodes on the client side.

using DevExpress.Web.ASPxTreeView;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
       DataBind();
       DefineImages(ASPxTreeView1.Nodes);
    }
    protected void DefineImages(TreeViewNodeCollection nodes) {
        foreach (TreeViewNode node in nodes) {
            if (node.Nodes.Count > 0) {
                node.Image.Url = "~/Images/closed_folder.png";
                DefineImages(node.Nodes);
            }
            else {
                node.Image.Url = "~/Images/file.png";
            }
        }
    }
}
See Also