DEV Community

Venkatesh Jonnagadla
Venkatesh Jonnagadla

Posted on

PowerBuilder - TreeView Control

Here is an example of Treeview control code -

integer li_a,li_b,li_c
long ll_level2
// First level Operationsw
li_a=tv_test.insertitemlast(0," First Generation",1)
li_b=tv_test.insertitemlast(0," Second Generation",1)
li_c=tv_test.insertitemlast(0," Third Generation",1)

// Second level under the First Generation i.e., li_a
tv_test.insertitemlast(li_a,"1G-1stItem",2)
tv_test.insertitemlast(li_a,"1G-2ndItem",2)

// Second level under the Second Generation i.e., li_b
tv_test.insertitemlast(li_b,"2G-1stItem",2)
ll_level2=tv_test.insertitemlast(li_b,"2G-2ndItem",2)
tv_test.insertitemlast(li_b,"2G-3ndItem",2)
tv_test.insertitemlast(li_b,"2G-4ndItem",2)
tv_test.insertitemlast(li_b,"2G-5ndItem",2)
tv_test.insertitemlast(li_b,"2G-6ndItem",2)

// sub level under second generation
tv_test.insertitemlast( ll_level2, "2G-2nItem-1SubItem", 3)


tv_test.insertitemlast(li_c,"3G-1stItem",2)
Enter fullscreen mode Exit fullscreen mode

To view the level and lable of the item you have clicked on a tree view control -

Selection Changed/Clicked on TreeView -

treeviewitem tvi_tvitem

//set treeview item here below
tv_test.getitem( newhandle, tvi_tvitem)

Messagebox(" Level of the treeview selected item ",String(tvi_tvitem.level))
Messagebox("Lable of the treeview Selected Item",tvi_tvitem.label)

Enter fullscreen mode Exit fullscreen mode

Thank you!!!!!!

Top comments (0)