[求助]几个郁闷的问题?
TreeView的问题
1.我从XML文件里读出Node,给TreeView,可是显示不出来
base.xml:
<Nodes id= "AllNodes " Text= "全部导入项 ">
<Color id= "Color " Text= "商品颜色 ">
</Color>
<Style id= "Style " Text= "商品样式 ">
</Style>
<SupNo id= "SupNo " Text= "厂商 ">
</SupNo>
<Class id= "Class " Text= "商品类别 ">
</Class>
<Largness id= "Largness " Text= "商品(赠品) ">
</Largness>
<Product id= "Product " Text= "商品(主品) ">
</Product>
<ColorAndStyle id= "ColorAndStyle " Text= "商品色样 ">
</ColorAndStyle>
<PandL id= "PandL " Text= "主赠品关系 ">
<Explain> 说明 </Explain>
</PandL>
</Nodes>
代码:
public TreeView GetLoadGuideItems()
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load(XMLFILEPATH);
XmlNode xnroot = xdoc.DocumentElement;
XmlNodeList xnl = xnroot.ChildNodes;
TreeView tv = new TreeView();
foreach (XmlNode xn in xnl)
{
TreeNode tn = new TreeNode();
tn.Name = xn.Attributes[ "id "].Value;
tn.Text = xn.Attributes[ "Text "].Value;
tv.Nodes.Add(tn);
}
return tv;
}
------解决方案--------------------up