日期:2014-05-17 浏览次数:20786 次
public static ArrayList CheckedCodes(TreeView pTree) {
ArrayList rList = new ArrayList();
TreeNodeCollection oNodes = pTree.Nodes;
short level = 0;
IList<IEnumerator> oNodeList = new List<IEnumerator>();
oNodeList.Add(oNodes.GetEnumerator());
while (level >= 0) {
IEnumerator enumer = oNodeList[level];
if (enumer.MoveNext()) {
TreeNode oNode = (TreeNode)enumer.Current;
rList.Add(new string(' ', level * 2) + oNode.Tag);
if (oNode.Nodes.Count > 0) {
level++;
oNodeList.Add(oNode.Nodes.GetEnumerator());
}
}
else {
oNodeList.RemoveAt(level);
level--;
}
}
return rList;
}