用C#语言如何操纵treeview控件?(10分)

  • 主题发起人 主题发起人 sjm
  • 开始时间 开始时间
S

sjm

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,哪位可以给一段全面操纵treeview控件的代码看看,谢谢啦!
 
兄弟 MSDN 非常详细!~
 
.NET Framework SDK的稳当中有
 
private void CreateTree()
{
TreeNode rootnode = new TreeNode();
rootnode.Text = "部门用户信息";
TreeView1.Nodes.Add(rootnode);
DataSet dsbm = new DataSet();
DataSet dsxm = new DataSet();
CommonDB = new Common();
CommonXM = new Common();

string sql,sqlsub;
sql = "Select Distinct B.BuMMC From BuMXXB B";
sql += " Order By BuMMC ";
dsbm = CommonDB.DataSets(sql);
foreach (DataRow dr in dsbm.Tables[0].Rows)
{
TreeNode treenode = new TreeNode();
treenode.Text = dr["BuMMC"].ToString().Trim();
rootnode.ChildNodes.Add(treenode);
sqlsub = "Select B.BuMMC,Y.XingM From BuMXXB B ,YongHXXB Y ";
sqlsub += "Where B.BuMBH=Y.QuanXBH And B.BuMMC= '" + treenode.Text + "'";
dsxm = CommonXM.DataSets(sqlsub);
foreach (DataRow drxm in dsxm.Tables[0].Rows)
{
TreeNode nodeXm = new TreeNode();
if (drxm["BuMMC"].ToString() == treenode.Text)
{
nodeXm.Text = drxm["XingM"].ToString();
treenode.ChildNodes.Add(nodeXm);
}
}
}
}
 

Similar threads

后退
顶部