日期:2014-05-19  浏览次数:21256 次

怎么获得Treeview节点的所有子节点
例如:
A
  a1
      a11
  a2
B  
  b1
  b2

怎么获得A下有a1,a11,a2,或者a1,a2;

------解决方案--------------------
System.String str = treeView1.SelectedNode.Text;//取得相应treeview结点的text值
bool remark=true;
for(int i=0; i <this.MdiChildren.Length;i++)
{
if(this.MdiChildren[i].Name.Equals( str )) //查看有没有相同的MDI子窗体
{
this.MdiChildren[i].Activate(); //子窗体已经被创立,激活它
remark=false;
break;
}
}
if(remark) // 未创立,建立子窗体
{
//Form4 temp_form = new Form4();
//temp_form.MdiParent=this;
//temp_form.Name=str;
//temp_form.Text=str;
//temp_form.Show();
switch(str)
{
case "采购管理 ":
采购管理 采管 = new 采购管理();
采管.MdiParent = this;
采管.Name = str;
采管.Text = str;
采管.Show();
break;
case "厂商资料 ":
CompanyInfo ComInfo = new CompanyInfo();
ComInfo.MdiParent = this;
ComInfo.Name = str;
ComInfo.Text = str;
ComInfo.Show();
break;
.......