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();
}
{
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();
}
解决方案 »
- 请问SpVoice语音读文本最大字符串限度是多少?
- 2个winForm窗体a,b,关闭b时,让a窗体中dataGridView控件刷新
- 如体获取DEVMODE结构中,打印机自定义的参数
- 一片毫无规律的xml如何用xsl t格式化
- 发布本人整理的面试问题大全,为准备找工作的同行们尽一份力!希望大家多补充或回答!
- 编写C#读取新浪RSS提示"403错误,访问被拒绝"
- 关于TextEdit和DateEdit的问题
- 在VS2013下怎么给C#的程序换肤?
- 求助啊ASP.NET求大神帮忙
- C#中ASII码转字符?
- 如果制作查找,替换功能?
- 如何获取Windows Form中Datagrid一个单元的值 .(新手)
现在TreeView有两层