List<ChinaStates> list = new ChinaData().SelectAll();//查询所有中国的城市的方法;
foreach (ChinaStates cs in list)
{
if (cs.ParentAreaCode == code)
{
TreeNode tn = new TreeNode(cs.AreaName);

dataBind(cs.AreaCode, tn.Nodes);

tnc.Add(tn);
}

}

把点击的城市,show出来:

string tname = "";
getData(treeView1.SelectedNode);
MessageBox.Show(tname.Substring(0, tname.Length - 1));

public void getData(TreeNode tn)
{
if (tn.Parent != null)
{
getData(tn.Parent);
}
tname += tn.Text + "|";
}

 

posted on 2017-11-30 15:17  我勒个去YCQ  阅读(288)  评论(0编辑  收藏  举报