日期:2014-05-20  浏览次数:21008 次

把xml文档的属性name和id绑定到ComboBox空间上
把xml文档的属性name和id绑定到ComboBox空间上
------解决方案--------------------
你可以把XML文件读出来,然后放在一个哈希表里面,再绑定到ComboBox控件上。
------解决方案--------------------
 //读取设定档 
 XmlDocument xmlDoc = new XmlDocument();
 xmlDoc.Load("你的XML文档路径");

 //取得节点 
 XmlNode xmlNode = xmlDoc.SelectSingleNode("Open");
 foreach (XmlNode item in xmlNode.ChildNodes)
 {
     comboBox1.Items.Add(new DictionaryEntry(item.Attributes["Name"].InnerText, item.Attributes["ID"].InnerText));
 }