private void settvw()//设置tvwrm
{
tvwrm.Nodes.Clear();
int index=0;
string nodeparent=null;
string nodechild=null;
SqlDataReader thisReader =Global.recordset("select * from rent_manage");
tvwrm.BeginUpdate();
while(thisReader.Read())
{
if(horinha=="house")//以房屋编号作为父节点
{
nodeparent=thisReader["houseid"].ToString();
nodechild=thisReader["inhabitantid"].ToString();
}
else//以业主编号作为父节点
{
nodeparent=thisReader["inhabitantid"].ToString();
nodechild=thisReader["houseid"].ToString();
}

TreeNode addnode=new TreeNode();
TreeNode addnodechild=new TreeNode();
bool same=false;
same=false;
foreach(TreeNode f in tvwrm.Nodes)
{
if(f.Text ==nodeparent)
{
same=true;
index=f.Index;
}
}
if (!same)
{
addnode.Text =nodeparent;
addnode.Tag ="parent";
if(horinha=="house")
{
addnode.ImageIndex=1;
addnode.SelectedImageIndex =1;
}
else
{
addnode.ImageIndex =0;
addnode.SelectedImageIndex =0;
}
tvwrm.Nodes.Add(addnode);
index=addnode.Index; addnodechild.Text =nodechild;
addnodechild.Tag ="child";
if(horinha=="house")
{
addnodechild.ImageIndex =0;
addnodechild.SelectedImageIndex =0;
}
else
{
addnodechild.ImageIndex =1;
addnodechild.SelectedImageIndex =1;
}
tvwrm.Nodes[index].Nodes.Add(addnodechild); }
else
{

addnodechild.Text =nodechild;
addnodechild.Tag ="child";
if(horinha=="house")
{
addnodechild.ImageIndex =0;
addnodechild.SelectedImageIndex =0;
}
else
{
addnodechild.ImageIndex =1;
addnodechild.SelectedImageIndex =1;
} tvwrm.Nodes[index].Nodes.Add(addnodechild);
} }
tvwrm.EndUpdate();
tvwrm.ExpandAll();
            
}