資源簡(jiǎn)介
C# winform實(shí)現(xiàn)combox綁定XML實(shí)現(xiàn)級(jí)聯(lián)數(shù)據(jù)綁定

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.xml;
namespace?xmlDemo2
{
public?partial?class?Form1?:?Form
{
xmlDocument?doc?=?new?xmlDocument();
public?Form1()
{
InitializeComponent();
doc.Load(“省市區(qū).xml“);
xmlNode?provinces?=?doc.SelectSingleNode(“/ProvinceCity“);
foreach?(xmlNode?province?in?provinces.ChildNodes)?{
cbxProvince.Items.Add(province.Name);
}
cbxProvince.SelectedIndex?=?0;
}
private?void?cbxProvince_SelectedIndexChanged(object?sender?EventArgs?e)
{
cbxCity.Items.Clear();
string?xpath?=?string.Format(“/ProvinceCity/{0}/City“?cbxProvince.SelectedItem.ToString());
xmlNodeList?cities?=?doc.SelectNodes(xpath);
foreach?(xmlNode?city?in?cities)?{
cbxCity.Items.Add(city.Attributes[“Name“].Value);
}
if(cbxCity.Items.Count?>=?0)?{
cbxCity.SelectedIndex?=?0;
}
}
private?void?cbxCity_SelectedIndexChanged(object?sender?EventArgs?e)
{
cbxCityArea.Items.Clear();
string?xpath?=?string.Format(“/ProvinceCity/{0}/City[@Name=‘{1}‘]/CityArea“?
cbxProvince.SelectedItem.ToString()
cbxCity.SelectedItem.ToString());
xmlNodeList?CityAreas?=?doc.SelectNodes(xpath);
foreach?(xmlNode?area?in?CityAreas)?{
cbxCityArea.Items.Add(area.Attributes[“Name“].Value);
}
if(cbxCityArea.Items.Count?>?0)?{
cbxCityArea.SelectedIndex?=?0;
}
}
}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????9728??2016-02-20?13:17??xm
?????文件??????26112??2016-02-20?13:17??xm
?????文件??????11608??2016-06-18?08:34??xm
?????文件????????490??2010-03-17?22:39??xm
?????文件?????116929??2013-06-09?14:46??xm
?????文件???????1576??2013-06-09?15:10??xm
?????文件???????2630??2013-06-09?15:10??xm
?????文件???????5817??2013-06-09?15:10??xm
?????文件???????1229??2016-05-27?09:09??xm
?????文件???????5289??2016-06-18?08:33??xm
?????文件???????3472??2013-06-09?15:10??xm
?????文件????????772??2013-06-09?15:10??xm
?????文件???????1281??2016-06-18?08:34??xm
?????文件????????902??2016-02-20?13:17??xm
?????文件???????9728??2016-02-20?13:17??xm
?????文件????????180??2016-02-20?13:17??xm
?????文件??????26112??2016-02-20?13:17??xm
?????文件????????180??2016-02-20?13:17??xm
?????文件????????391??2013-06-09?14:50??xm
?????文件???????1366??2013-06-09?14:50??xm
?????文件???????2513??2013-06-09?14:50??xm
?????文件???????5612??2013-06-09?14:50??xm
?????文件???????1015??2013-06-09?14:50??xm
?????文件????????249??2013-06-09?14:50??xm
?????文件???????3423??2013-06-09?14:50??xm
?????文件????????866??2013-06-09?14:50??xm
????..A..H.?????16384??2016-06-18?17:31??xm
?????目錄??????????0??2013-06-09?14:50??xm
?????目錄??????????0??2016-05-27?09:09??xm
?????目錄??????????0??2013-06-09?14:51??xm
............此處省略10個(gè)文件信息
- 上一篇:C# excel轉(zhuǎn)vcf生成器
- 下一篇:c# 打怪獸的游戲
評(píng)論
共有 條評(píng)論