Populating a treeview with two tables using vb.net -
hello have 2 tables:
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
-dshrd
-pa
-payben
-ps
-pldacounting
-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
Post a Comment