Home > database >  Consult the treeview
Consult the treeview

Time:09-17

Consult each master, I want to use the treeview to show the hierarchy of a company, such as a root node is the head office, head office have many branches below, under the branch has many departments, department and group below, temporarily the level 4 level, could you tell me how to achieve?
Because I used pb for so long, have forgotten about, trouble can you provide a detailed a little demo, thank you.

CodePudding user response:

[tectonic events]
Treeviewitem ltvi
Long ll_handle
Ltvi. PictureIndex=2
Ltvi. SelectedPictureIndex=1
Ltvi. Selected=False
Ltvi. Children=True
Ltvi. Data='https://bbs.csdn.net/topics/%'
Ltvi. Label="corporation"
Ll_handle=tv_1. InsertItemLast (0, ltvi)
Tv_1. ExpandItem (ll_handle)


[itempopulate events]
Treeviewitem ltvi, ltvi_parent
If tv_1. The GetItem (Handle, ltvi_parent) & lt; & gt; 1 Then Return
DECLARE c1 CURSOR FOR the SELECT item_class, class_name, class_data
The FROM t_item_class WHERE item_class LIKE: ls_like
AND item_class & lt; & gt; : ls_no ORDER BY 1;
The OPEN c1;
Do
The FETCH c1 INTO: ls_no, ls_name, : ls_three;
If the sqlca. SQLCode & lt; & gt; 0 Then the Exit
If gvar. Grant_clsno & lt; & gt; "" Then
If PosA (gvar grant_clsno, "'" + ls_no + "'")=0 Then the Continue
End the If
Ls_name=corp pub_f_str2str (ls_name)
Ls_three=corp pub_f_str2str (ls_three)
Ltvi. Data=https://bbs.csdn.net/topics/ls_no
+ ls_name ls_name=ls_no + ". "
If ls_three & lt; & gt; "" And ls_three & lt; & gt; + ls_three ls_no Then ls_name +="(" +") "
Ltvi. Label=ls_name
Ltvi. Children=wf_have_child (" CLS ", ls_no)
Tv_1. InsertItemLast (Handle, ltvi)
Lb_have_child=True
Loop While True
The CLOSE c1;


From a program to copy the code, look at yourself

CodePudding user response:

[] itempopulate event is the first time, here is the load at all levels,

CodePudding user response:

PB in the treeview tree view code example

The Open event code:
Treeviewitem ltvi_data//define a tree view variable
Datastore lds_place//define the first data storage
Int I, li_num_place
Long handle
Lds_place=create datastore//store the data associated with the data window object
Lds_place. Dataobject="d_bm"
Lds_place. Settransobject (sqlca)
Li_num_place=lds_place. Retrieve ()//retrieve data
For I=1 to li_num_place//cycle insert the first layer node data
Ltvi_data. Label=lds_place. Getitemstring (I, "bm")//for the tree view label assignment
ltvi_data.data=https://bbs.csdn.net/topics/lds_place.getitemstring (I, "bm1")//for the tree view DATA variable (ANY type) to define a want to save DATA
Ltvi_data. Pictureindex=1//define image index
Ltvi_data. Selectedpictureindex=2//define the selected icon
Ltvi_data. Children=true//there is still a child at a lower level specifies the node
Handle=tv_1. Insertitemlast (0, ltvi_data)//insert node

Next
Destroy lds_place//release defined data storage
===========================
ItemPopulate event code:
Treeviewitem ltvi_data, ltvi_place
Datastore lds_person//define the second data storage
Int j, li_num_person
Long handle1
If this. The getitem (handle, ltvi_place)=1 then return//return 1 if the data is retrieved is unsuccessful
Lds_person=create datastore//for data storage assignment
Lds_person. Dataobject="d_bm1"//a connection for data storage in the second data window object, the object will need to use SQL SELECT as a data source and define a retrieve parameter
Lds_person. Settransobject (sqlca)
Li_num_person=lds_person. Retrieve (ltvi_place. Data)//the node of the data value passed as a parameter to the second data window object
For j=1 to li_num_person//cycle insert the second node

Ltvi_data. Label=lds_person. Getitemstring (j, "name")
Ltvi_data. Pictureindex=3
Ltvi_data. Selectedpictureindex=4
Ltvi_data. Children=false
Handle1=tv_1. Insertitemlast (handle, ltvi_data)
Next
Destroy lds_person//release data storage

CodePudding user response:

You can refer to the link


http://blog.sina.com.cn/s/blog_4640dfa501000awf.html
  • Related