TreeView.ImageSet Property

Gets or sets the group of images to use for the TreeView control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public TreeViewImageSet ImageSet { get; set; }
<asp:TreeView ImageSet="TreeViewImageSet" />

Property Value

Type: System.Web.UI.WebControls.TreeViewImageSet
One of the TreeViewImageSet values. The default is TreeViewImageSet.Custom.

ExceptionCondition
ArgumentOutOfRangeException

The specified image set is not one of the TreeViewImageSet values.

Use the ImageSet property to specify the group of images to use for the TreeView control. You can either select a predefined set of images to give the control a standard look or define your own custom set.

NoteNote

The ImageSet property does not affect any style settings for a node. Set the appropriate style property, such as the NodeStyle property, if you want to add custom colors and spacing.

The following table lists the valid values for The ImageSet property.

Image set

Description

TreeViewImageSet.Arrows

A predefined image set that uses arrow images.

TreeViewImageSet.BulletedList

A predefined image set that uses diamond-shaped bullet images.

TreeViewImageSet.BulletedList2

A predefined image set that uses square-shaped bullet images.

TreeViewImageSet.BulletedList3

A predefined set of sectioned, diamond shaped bullet images.

TreeViewImageSet.BulletedList4

A predefined set of alternate sectioned, diamond shaped bullet images in sizes that vary by level.

TreeViewImageSet.Contacts

A predefined image set that uses MSN Messenger images.

TreeViewImageSet.Custom

A user-defined image set.

TreeViewImageSet.Events

A predefined image set that uses event log-styled images.

TreeViewImageSet.Faq

A predefined image set that uses FAQ-styled images.

TreeViewImageSet.Inbox

A predefined image set that uses e-mail-styled images.

TreeViewImageSet.News

A predefined image set that uses newsgroup-styled images.

TreeViewImageSet.Simple

A predefined image set that uses simple shape outlines.

TreeViewImageSet.Simple2

A predefined image set that uses simple filled shapes.

TreeViewImageSet.Msdn

A predefined image set that uses MSDN images.

TreeViewImageSet.WindowsHelp

A predefined image set that uses Microsoft Windows Help images.

TreeViewImageSet.XPFileExplorer

A predefined image set that uses Windows Explorer images available in Microsoft Windows XP.

When defining a custom set of images, you should specify an image for each of the properties in the following table. Otherwise, the default image for that property is used.

Property

Description

CollapseImageUrl

The URL to a custom image for the collapsible node indicator.

ExpandImageUrl

The URL to a custom image for the expandable node indicator.

LineImagesFolder

The URL to a folder that contains custom images for the lines that connect nodes.

NoExpandImageUrl

The URL to a custom image for the non-expandable node indicator.

The value of this property is stored in view state.

The following code example demonstrates how to use the ImageSet property to display the Windows Explorer set of images in the TreeView control.



<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeView ImageSet Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>TreeView ImageSet Example</h3>

      <asp:TreeView id="LinksTreeView"
         ImageSet="XPFileExplorer" 
         runat="server">

        <Nodes>

          <asp:TreeNode Value="Home" 
            NavigateUrl="Home.aspx" 
            Text="Home"
            Target="_blank" 
            Expanded="True">

            <asp:TreeNode Value="Page 1" 
              NavigateUrl="Page1.aspx" 
              Text="Page1"
              Target="_blank">

              <asp:TreeNode Value="Section 1" 
                NavigateUrl="Section1.aspx" 
                Text="Section 1"
                Target="_blank"/>

            </asp:TreeNode>              

            <asp:TreeNode Value="Page 2" 
              NavigateUrl="Page2.aspx"
              Text="Page 2"
              Target="_blank">

            </asp:TreeNode> 

          </asp:TreeNode>

        </Nodes>

      </asp:TreeView>

    </form>
  </body>
</html>



.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2015 Microsoft