哦~
你在你treeView控件的安装目录下,找到webctrl_client目录,然后把该目录设置一个虚拟目录就可以了~

解决方案 »

  1.   

    为什么现在问问题的都不注明是winform还是webform啊?晕
      

  2.   

    非常感谢kenMoxi(恶魔) 问题解决了
    我的问题是web的
      

  3.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!Page.IsPostBack )
    {
    createroot();                //创建树
    adduser();                        //树中加用户

    }
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void createroot()                                                      //创建根节点
    {
    SqlConnection myConnection;
    myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectString"]);        
    SqlDataAdapter myCommand = new SqlDataAdapter("select dep_name,dep_id from sys_dep_master", myConnection);
    DataSet ds = new DataSet();                                                 //取得所有群组名(根)
    myCommand.Fill(ds, "t1");                                       //保存sys_dep_master的所有dep_name,dep_id

                    
    for(int i=0;i<=ds.Tables [0].Rows.Count -1;i++)            
    {
    TreeNode t1=new TreeNode ();
    t1.ImageUrl =@"../../image/tree/root.gif";
    t1.ID=ds.Tables [0].Rows [i][1].ToString (); 
    t1.Text =ds.Tables [0].Rows [i][0].ToString ();               //取得所有dep_name和id
    TreeView1.Nodes.Add(t1);                                       //所有群组名加到根目录 string id=t1.ID ;         
    InitTree(t1.Nodes,id);                                           //调用InitTree函数 形成所有子树

    }
    }



    private void InitTree(TreeNodeCollection Nds,string masterId)
    {
    string str;
    SqlConnection myConnection;
    myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectString"]);   
    str="select * from sys_dep_chi where master_dep_id="+"'"+masterId+"'";         
    SqlDataAdapter myCommand = new SqlDataAdapter(str, myConnection);
    DataSet ds = new DataSet();
    myCommand.Fill(ds, "t1"); for(int i=0;i<=ds.Tables ["t1"].Rows.Count-1;i++)
    {
    TreeNode tmpNd=new TreeNode();
    tmpNd.ID =ds.Tables ["t1"].Rows[i][0].ToString ();
    tmpNd.Text =ds.Tables ["t1"].Rows[i][1].ToString ();
    tmpNd.ImageUrl =@"../../image/tree/root1.gif";
    Nds.Add (tmpNd);
    InitTree(tmpNd.Nodes,tmpNd.ID);                              //递归调用 }
    } private void adduser()                                              //添加用户
    {
    GetAllNode(TreeView1.Nodes); }
    void GetAllNode(TreeNodeCollection tnc)                          //遍历树的每个节点
    {
    foreach(TreeNode node in tnc)
    {
    if(node.Nodes.Count!=0)
    GetAllNode(node.Nodes);
    adduser1(node.Nodes ,node.ID );                //每个节点的nodes集合和id作为参数,构造树
    } } private void adduser1(TreeNodeCollection tnc,string id)                //每个节点添加用户
    {
    SqlConnection myConnection;
    myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectString"]);        
    SqlDataAdapter myCommand = new SqlDataAdapter("select user_name,a.user_id,dep_id from sys_user as a,sys_user_dep as b where a.user_id=b.user_id", myConnection);
    DataSet ds = new DataSet();                  
    myCommand.Fill(ds, "t1"); for(int i=0;i<=ds.Tables ["t1"].Rows.Count -1;i++)    
    if(id ==ds.Tables ["t1"].Rows[i][2].ToString ())
    {
    TreeNode t1=new TreeNode ();
    t1.ImageUrl =@"../../image/tree/person.gif";
    t1.ID =ds.Tables ["t1"].Rows[i][1].ToString ();
    t1.Text =ds.Tables [0].Rows [i][0].ToString ();
    tnc.Add (t1); }
    }
      

  4.   

    "你在你treeView控件的安装目录下,找到webctrl_client目录,然后把该目录设置一个虚拟目录"
    ————不明白,见笑了。