System.Web.UI.WebControls Namespace TreeView Class
.NET Framework version 2.0
Sets or retrieves the group of images to use for a TreeView control.
Script |
[ TreeViewImageSet enumValue = ] TreeView.ImageSet |
The property is read/write with a default value of Custom.
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.
NOTE: 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.
Member Name |
Description |
Arrows |
A predefined set of arrow images. |
BulletedList |
A predefined set of diamond-shaped bullet images. |
BulletedList2 |
A predefined set of square-shaped bullet images. |
BulletedList3 |
A predefined set of sectioned, diamond shaped bullet images. |
BulletedList4 |
A predefined set of alternate sectioned, diamond shaped bullet images in sizes that vary by level. |
Contacts |
A predefined set of MSN Messenger–styled images. |
Custom |
A user-defined set of images. This is the default value of the
ImageSet. |
Events |
A predefined set of event log–styled images. |
Faq |
A predefined set of FAQ-styled images. |
Inbox |
A predefined set of e-mail–styled images. |
Msdn |
A predefined set of Microsoft MSDN developer program–styled images. |
News |
A predefined set of newsgroup-styled images. |
Simple |
A predefined set of simple-shaped outline images. |
Simple2 |
A predefined set of filled simple-shaped images. |
WindowsHelp |
A predefined set of Microsoft Windows Help–styled images. |
XPFileExplorer |
A predefined set of Windows Explorer for Microsoft Windows XP–styled images. |
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 example below shows how to programmatically set the ImageSet property at run time, depending on user input. The code also demonstrates how simple it is to retrieve the available system image sets and dynamically add each to a selectable list.
<script language = "C#" runat = "server">
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
ICollection borders = TypeDescriptor.GetConverter (
typeof ( TreeViewImageSet ) ).GetStandardValues ( );
foreach ( TreeViewImageSet b in borders ) {
ImageSetSelect.Items.Add ( b.ToString ( ) );
}
}
myTreeView.ImageSet = ( TreeViewImageSet ) ImageSetSelect.SelectedIndex;
}
</script>
Show me
TreeView Members