Populating a treeview with two tables using vb.net -


hello have 2 tables:

enter image description here

subdepartment table

then want result using treeview:

id department category

  • 1 mis system 1 mis networking 1 mis programmer
  • 2 audit operations 2 audit ds
  • 3 hrd pa 3 hrd payben 3
    hrd ps 3 hrd pld
  • 4 acounting sup 4 acounting fmcg
  • 5 procurement null

or this

  • mis

-system
-networking
-programmer

  • audit
    -operations
    -ds

  • hrd
    -pa
    -payben
    -ps
    -pld

  • acounting
    -sup
    -fmcg

can please guide me, thank you. i'm having trouble finding solution on internet , i'm new vb.net language.

in code below, give logic. need query tables now.

tell me if need explanations.

    treeview1.nodes.clear()      'create first node , select     dim root treenode = treeview1.nodes.add("test")     treeview1.selectednode = root      'create 2 types of node     dim department new treenode()     dim category new treenode()      'daos (if create department class , subdepartment class)     dim _daod new departments(_cnx)     dim _daosd new subdepartments(_cnx)      'lists (depending on classes too)     dim listd list(of department)     dim listsd list(of subdepatment)      each dep department in listd         'add tree node new department         department = new treenode(dep.department)         department.tag = dep.id         root.nodes.add(department)         treeview1.selectednode = departement          each subdep subdepartment in listsubdep             'add treenode new categories             categ = new treenode(subdep.category)             categ.tag = subdep.id             nodes.add(categ)         next     next 

then, can create 4 classes (the first 1 properties, , second 1 query in table)

public class department      'properties         public property id integer                     return _id         end         set(byval value integer)             _id = value         end set     end property    'etc end class  public class departments     dim _cnx oracleconnection (if use oracle)     public sub new(byval pcnx oracleconnection)         _cnx = pcnx     end sub     'your queries end class 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -