Du skal lave en custom treenode control:
Setting a per-node background image:
// BG images for TreeNodes
// This version adds two features.
// 1) it adds a specific property whose value is consumed
// 2) it injects an additional control (<div>) into the rendering
public class BGTreeNode : TreeNode
{
// This constructors is needed if a custom TreeView
// instantiates this in CreateNode
public BGTreeNode() : base() { }
public BGTreeNode(TreeView owner, bool isRoot) :
base(owner, isRoot) { }
private string _bgImageUrl;
public string BackGroundImageUrl
{
get { return _bgImageUrl; }
set { _bgImageUrl = value; }
}
protected override void RenderPreText(HtmlTextWriter writer)
{
writer.AddStyleAttribute(
HtmlTextWriterStyle.BackgroundImage,
"url('" + BackGroundImageUrl + "')");
//writer.AddStyleAttribute(
// HtmlTextWriterStyle.Height, "35px");
//writer.AddStyleAttribute(
// HtmlTextWriterStyle.Width, "300px");
writer.AddStyleAttribute(
HtmlTextWriterStyle.TextAlign,
"center");
writer.RenderBeginTag( HtmlTextWriterTag.Div );
base.RenderPreText(writer);
}
protected override void RenderPostText(HtmlTextWriter writer)
{
writer.RenderEndTag();
base.RenderPostText(writer);
}
}
Den er taget her fra:
http://216.239.59.104/search?q=cache:CmKKaIOJ3X0J:weblogs.asp.net/dannychen/+asp.net+TreeNode+background+image&hl=da&gl=dk&ct=clnk&cd=2&client=firefox-a