要实现下面这样的功能代码应该怎么写?给定一个值,遍历treeview节点,如果子节点的值等于给定值,则展开他的父节点,如果父节点的值等于给定值则父节点就展开自己!树像下面这样value和text一样:
pc:
ibm
microsoftgame:
xbox
ps2我像下面这么写为什么不正确?foreach(TreeNode tn in tv1.Nodes)
{
if (tn.Value == "ps2")
{
if (tn.Parent == null)
{
tn.Expand();
}
else if (tn.Parent != null)
{
tn.Parent.Expand();
}
}
}
pc:
ibm
microsoftgame:
xbox
ps2我像下面这么写为什么不正确?foreach(TreeNode tn in tv1.Nodes)
{
if (tn.Value == "ps2")
{
if (tn.Parent == null)
{
tn.Expand();
}
else if (tn.Parent != null)
{
tn.Parent.Expand();
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货