Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. working on treeview

working on treeview

Scheduled Pinned Locked Moved C#
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thirdy33
    wrote on last edited by
    #1

    how can i edit,remove and add a node on a treeview in the runtime?

    M P 2 Replies Last reply
    0
    • T thirdy33

      how can i edit,remove and add a node on a treeview in the runtime?

      M Offline
      M Offline
      mrcooll
      wrote on last edited by
      #2

      the following code snippet generate classes nodes has a childe nodes "Semester"

      private void FillTreeNodes()
      {
      SysClass sysclass = new SysClass();
      DataSet ds= sysclass.GetAllSysClasss();

          TreeNode node;
          
          foreach (DataRow row in ds.Tables\[0\].Rows)
          {
              node = new TreeNode();
              node.Text = row\["Class"\].ToString();
              node.Value = row\["ClassId"\].ToString();
              node.NavigateUrl = "UpdateClass.aspx?classId="+node.Value;
              GenerateSemesters(node,int.Parse(row\["ClassId"\].ToString()));
              tree1.Nodes.Add(node);
          }
      }
      
      private void GenerateSemesters(TreeNode node,int classid)
      {
       Semester semester=new Semester();
       DataSet ds = semester.GetAllSemesters(classid);
          TreeNode childenode;
          foreach (DataRow row in ds.Tables\[0\].Rows)
          {
              childenode = new TreeNode();
              childenode.Text = row\["SemesterName"\].ToString();
              childenode.Value = row\["SemesterId"\].ToString();
              childenode.NavigateUrl = "Updatesemester.aspx?semesterId=" + childenode.Value;
              
             
              node.ChildNodes.Add(childenode);
          }
      }
      

      i forget to minsion that is the best way for filling treeview is recursively !

      modified on Monday, March 29, 2010 4:46 AM

      1 Reply Last reply
      0
      • T thirdy33

        how can i edit,remove and add a node on a treeview in the runtime?

        P Offline
        P Offline
        Praveen Raghuvanshi
        wrote on last edited by
        #3

        Hope this helps http://www.c-sharpcorner.com/uploadfile/scottlysle/treeviewbasics04152007195731pm/treeviewbasics.aspx

        Praveen Raghuvanshi Software Engineer, India.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups