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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Treeview Problem

Treeview Problem

Scheduled Pinned Locked Moved C#
csharphelpjavadatabasevisual-studio
2 Posts 2 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.
  • D Offline
    D Offline
    Digubha
    wrote on last edited by
    #1

    I am new to C#.Net window application. I have table categories where the following values are stored. 1 Software 0 0 2 Hardware 0 0 3 Electronics 0 0 4 Others 0 0 5 Adobe 1 0 6 Pen Drive 2 0 7 Adapter 3 0 8 C# 4 0 9 avast 1 0 10 Microsoft 1 0 11 avg 1 0 12 Cardreader 2 0 13 monitor 2 0 14 mobile 3 0 15 camera 3 0 16 Java 4 0 17 .Net 4 0 18 ad2001 5 0 19 ad2005 5 0 20 amkette 6 0 21 iball 6 0 22 ad#1 7 0 23 ad#2 7 0 24 vs2005 8 0 25 vs2008 8 0 NULL NULL NULL NULL Now I want the tree view control which can be populated as I show it below: Software Adobe ad2001 ad2008 avast Microsoft avg Hardware Pendrive amkette iball Cardreader monitor Electronics adaptor ad#1 ad#2 mobile camera Others C# vs2005 vs2008 Java .Net You can see the relation between Cate and MC The child node’s MC = Cate of Parent Node. I am finding problem to construct treeview in visual studio 2005 and C#.Net window application. The Main Problem is : 1) How can we count the parent , child and grandchild node by firing query? 2) How can we add childnode at exact below its correct parent node? 3) How can we display the information in Listview from table for selected node? Please help me on this topic and get bless from god! My project has to be completed in next 2 days. Please help me! Thanx In advance!

    X 1 Reply Last reply
    0
    • D Digubha

      I am new to C#.Net window application. I have table categories where the following values are stored. 1 Software 0 0 2 Hardware 0 0 3 Electronics 0 0 4 Others 0 0 5 Adobe 1 0 6 Pen Drive 2 0 7 Adapter 3 0 8 C# 4 0 9 avast 1 0 10 Microsoft 1 0 11 avg 1 0 12 Cardreader 2 0 13 monitor 2 0 14 mobile 3 0 15 camera 3 0 16 Java 4 0 17 .Net 4 0 18 ad2001 5 0 19 ad2005 5 0 20 amkette 6 0 21 iball 6 0 22 ad#1 7 0 23 ad#2 7 0 24 vs2005 8 0 25 vs2008 8 0 NULL NULL NULL NULL Now I want the tree view control which can be populated as I show it below: Software Adobe ad2001 ad2008 avast Microsoft avg Hardware Pendrive amkette iball Cardreader monitor Electronics adaptor ad#1 ad#2 mobile camera Others C# vs2005 vs2008 Java .Net You can see the relation between Cate and MC The child node’s MC = Cate of Parent Node. I am finding problem to construct treeview in visual studio 2005 and C#.Net window application. The Main Problem is : 1) How can we count the parent , child and grandchild node by firing query? 2) How can we add childnode at exact below its correct parent node? 3) How can we display the information in Listview from table for selected node? Please help me on this topic and get bless from god! My project has to be completed in next 2 days. Please help me! Thanx In advance!

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      I wrote a code for this a month ago but now I do not remember it correctly. However, I'll try to explain ;) All you need a funtion and a generic list to hold all these values. eg.

      public class ValuesHolder
      {
      public int ID;
      public int ParentID;
      public string Text;
      public ValuesHolde(int id, int parentID, string text)
      {
      // set values here
      }
      }

      List<valuesholder> ValuesHolder_List = new List<valuesholder>();
      ValuesHolder_List.Add(new ValuesHolde(id, parentID, text)); // an example

      for (int a = 0; a < ValuesHolder_List.Count; a++)
      {
      if (ValuesHolder_List[a].ParentID == 0)
      {
      TV.Nodes.Add(ValuesHolder_List[a].ID, ValuesHolder_List[a].Text);
      ValuesHolder_List.RemoveAt(a--); // delete that item as well as a step back
      }
      }

      while (ValuesHolder_List.Count != 0)
      {
      for (int a = 0; a < ValuesHolder_List.Count; a++)
      {
      TreeNode[] tns = TV.Nodes.Find(ValuesHolder_List[a].ParentID, true);
      if (tns.Length > 0)
      {
      tns[0].Nodes.Add(ValuesHolder_List[a].ID, ValuesHolder_List[a].Text);
      ValuesHolder_List.RemoveAt(a--); // delete that item as well as a step back
      }
      }
      }

      I didn't test the code, but I'm sure it'll help you.

      TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKQUFK[M`UKs*$GwU#QDXBER@CBN% R0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i’TV.C\y<pŠjxsg-b$f4ia>

      ----------------------------------------------- 128 bit encrypted signature, crack if you can

      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