我有两个类,一个来自TreeView,另一个来自TreeNode:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Resources;
using ExtendedTreeView.Properties;
namespace ExtendedTreeView
{
public partial class ExtendedTreeView : System.Windows.Forms.TreeView
{
public ExtendedTreeView()
{
InitializeComponent();
ImageList il = new ImageList();
il.Images.Add("blank", Resources.favicon);
il.Images.Add("application", Resources.application);
il.Images.Add("computer", Resources.computer);
il.Images.Add("network", Resources.network);
il.Images.Add("session", Resources.session);
il.Images.Add("user", Resources.user);
il.Images.Add("usergroup", Resources.usergroup);
this.ImageList = il;
}
}
}
和
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.NetworkInformation;
using System.Management;
using System.Windows.Forms;
using Cassia;
using System.Security.Principal;
namespace GUI
{
public class Computer : System.Windows.Forms.TreeNode, IDictionaryEnumerator
{
private DictionaryEntry nodeEntry;
private IEnumerator enumerator;
public String computerName { get; private set; }
public Computer(String computername)
{
this.computerName = computername;
enumerator = base.Nodes.GetEnumerator();
this.Text = this.ipAdressen[0].ToString() + " - " + this.computerName;
this.ImageIndex = 2;
}
#region TreeNodeStuff
public string NodeKey
{
get
{
return nodeEntry.Key.ToString();
}
set
{
nodeEntry.Key = value;
}
}
public object NodeValue
{
get
{
return nodeEntry.Value;
}
set
{
nodeEntry.Value = value;
}
}
public DictionaryEntry Entry
{
get
{
return nodeEntry;
}
}
public bool MoveNext()
{
bool Success;
Success = enumerator.MoveNext();
return Success;
}
public object Current
{
get
{
return enumerator.Current;
}
}
public object Key
{
get
{
return nodeEntry.Key;
}
}
public object Value
{
get
{
return nodeEntry.Value;
}
}
public void Reset()
{
enumerator.Reset();
}
#endregion
}
}
但TreeNode-Icons卡在索引0处。所以我的问题是,我无法设置计算机TreeNode的ImageIndex属性。 我做错了什么?