treeview

How can I create a tree view?
wesamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wesamAuthor Commented:
Urgent
0
SylvainPouliotCommented:
What's your problem?
There's already a treeview object in powerbuilder...
0
NMiCommented:
1. First of all, you must have some suitable object that will contain your treeview - a window, a tabpage, or something.
2. Assuming you're using PB as RAD tool, you place the TreeView object in the container - hope you can do that ;)
3. Enter this object's properties - assign an appropriate name (first tab), assign some icons to its tree levels (second tab), and that should do for the first time.
4. Make some command button to test your treeview. In the 'clicked' event of that button, you should write:

tv_YOURNAME.InsertItemFirst(0, "My first Level", 1)

Description
Inserts an item as the first child of its parent.

Syntax

treeviewname.InsertItemFirst ( handleparent, label, pictureindex )
Argument     Description
treeviewname     The TreeView control in which you want to specify an item as the first child of its parent
handleparent     The handle of the item that will be the inserted item's parent. To insert the item at the first level, specify 0
label     The label of the item you want to specify as the first child of its parent
pictureindex     The picture index for the item you want to specify as the first child of its parent
Return value
Long. Returns the handle of the item inserted if it succeeds and -1 if an error occurs.


Next, run your application and click the button - your first item should appear at the very first treeview level, accompanied with an icon of your choice.

The TreeView controls are an excellent example of user-friendly interface that your users would love to use. Have fun ! :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BhattiCommented:
Hello Wesam,

Please try the following:

This is an example and you can then put your data to commplete you task.

long ll_lev1, ll_lev2 ,ll_lev3 ,ll_lev4

int index

tv_list.PictureHeight = 32

tv_list.PictureWidth = 32

ll_lev1 = tv_list.InsertItemFirst(0,"Composers",1)

ll_lev2 = tv_list.InsertItemLast(ll_lev1, "Beethoven",2)

ll_lev3 = tv_list.InsertItemLast(ll_lev2, "Symphonies", 3)

FOR index = 1 to 9

   ll_lev4 = tv_list.InsertItemSort(ll_lev3, "Symphony # " + String(index) , 4)

NEXT
tv_list.ExpandItem(ll_lev3)

tv_list.ExpandItem(ll_lev4)


This just example fom the PB help.

put your control in the window and then in the cinstuction event write thems script and name to treeview as tv_list.


run the programm and doubleclicked the composers and then you will + sign and clicked the + sign and you will further.

type in help treeview and then functions:

Imporant functions:

Insertitemfirst()
Insertitem()
and others will help you to create a beautiful treeview.


If you become questions please let me know.

Best regards


Bhatti
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.