TreeView and TreeView Plus query

RacingDog

Active Member
Licensed User
I think it's me being blind again, but I can't see any way to track what the user does in terms of expanding and collapsing branches of the tree. I had in mind that I would like to record the tree state so that at a subsequent date I can give the user the same visual display that he last used. Any comments? Ta.

It has since occured to me that I need to know that to switch between open and closed folder images too.
 
Last edited:

RacingDog

Active Member
Licensed User
Is anybody going to comment on this please?

The TV Action property may well have a value expanded or collapsed, but that is totally useless when there is no AfterSelect event generated by clicking on the Plus/Minus symbol.

Strangely, whilst I've used TVs before, I've never been in an open/closed imagery scenario before as an author, so this is a bit of an uknown to me. I dug out my old XP latop. Hmm. Looks like Plus/Minus has always been a bit of a hole in the visual paradigm, for example in XP WE, using Plus's to display a child folder and then selecting the child leaves the parent shown closed, whereas selecting the parent, then the child leaves both shown open. Isn't that just wonderfully consistent from the user's view? The latter is visually correct.

So are Plus/Minus symbols just a historical problem? Have I got that right?

Also, just relying on ImageIndex and SelectedImageIndex to implement visual indications of open/closed folders isn't adequate. Selecting a child causes the parent, which by anybody's definition is still open, to be shown as closed because it is no longer selected. No. It is still open. You are looking inside it. That is the wrong action.

What about the following workaround for that latter problem? On selecting a node, I should set all ImageIndex-s of the parents chain to the open image, save the index of the selection, then on the next selection use the saved index to return that node and all it's parents to the closed image (except on the first selection) as well as performing the open indications and index saving. I'll give it whirl anyway.

Edit : Whirl successful!

Cheers.
 
Last edited:

derez

Expert
Licensed User
Longtime User
RacingDog
I don't understand the meaning of open and closed in your discussion.
The Plus , as I understand it, means that there are subdirectories or files at that directory, which are not visible. A Minus means that they are visible.
I don't see any relation to Open or Closed.
We know the meaning of an open file otherwise - a file that is used currently for reading or writing, and that is not shown in the treeview at all.
What images do you use for open and closed ?
 

RacingDog

Active Member
Licensed User
Yes you do know what I mean David, grin!

The open and closed folder images used by Windows Explorer, Directory and file pickers, Open and SaveAs dialogs since time immemorial. I extracted them as .gifs from \Windows\system32\shell32.dll using the freebie IcoFx.

If you click or tap on a file in a folder (or any other type child item in some parent that you are representing as a folder), you expect the display of the folder icon to show as Open. If you check with W.E. (XP and earlier, I never used Vista, but W7 sadly seems to have stopped using that scheme) you will also see that all parent folders show as Open as well. Therefore, if you try to do the same with a Treeview, you can't just rely on ImageIndex for the Closed image and SelectedImageIndex for the Open image, you have to do some extra work, because you need the images of more than one node to change.
 

derez

Expert
Licensed User
Longtime User
I work with windows for many years and never noticed the difference between open and closed directory, until your post !

My direct conclusion from this fact is that this differentiation is not necessary and may be ommited in the TV (as it is missing there now)
 

RacingDog

Active Member
Licensed User
As they say on our TV ads, "Should have gone to Specsavers"! :D

I wasn't saying TV should change, I was trying to establish where the extra work was needed. The answer is in the app.

Now you know, I bet you won't stop noticing, especially where other people haven't done the job that way!

There is still the problem of how you can record the user's Plus/Minus settings, if that is what is required. I can't see any way of doing it and looking at the framework help file above didn't suggest anything either. Maybe it can't be done.
 

derez

Expert
Licensed User
Longtime User
In TvDialog I save the last selected file or directory and use the path for the next opening of the dialog. The path is stored in a text file.

This means that what you need can be done up to the level that we are looking and a straight line of directories from the root to the last.

check TvDialog and see if this answers your need. Look at DrawTree private method there - it opens one level at a time, following the recorded path.
 
Top