首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET Framework >

把xml文档的属性name跟id绑定到ComboBox空间上

2013-03-26 
把xml文档的属性name和id绑定到ComboBox空间上把xml文档的属性name和id绑定到ComboBox空间上[解决办法]你

把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));
 }

热点排行