Hi,
does anyone know if there is an example anywhere of how to create a hierarchical listbox for OS X?
Thank you all in advance.
Hi,
does anyone know if there is an example anywhere of how to create a hierarchical listbox for OS X?
Thank you all in advance.
Did you into examples included with Xojo?
/Example Projects/Desktop/Controls/ListBox/FileBrowser.xojo_binary_project
Thanks Christian / Axel.
I think I must have delete some example folders, as I looked there first of all, but they didn’t exist?
I have just re-downloaded them, and now have them
Thanks.
OK - this has me puzzled:
I have created a new project file, and dragged in a Listbox which is set to hierarchical.
I can add this code in the Listbox.open event - which successfully creates 2 Main Folders:
Me.AddFolder"Folder1"
Me.AddFolder"Folder2"
Is there a relatively simple way to now add 2 sub folders to each of these, and then add 2 normal rows to each of these 2 subfolders?
I’m sure this is probably ridiculously simple, but I’m staring at it, and nothing makes any sense
Any help appreciated.
Thank you all in advance.
normally you get sub rows using Expand event. You can expand them in code by setting expanded(row) property.
Or you check the indent parameter for InsertFolder/InsertRow methods.
Thanks Christian, but I still cannot work out how to do this
Does anyone by chance have an example project which simply shows how to have a TWO level hierarchical listbox?
I can then spend hours looking at the code, and work out what is happening.
I simply need a hierarchical listbox, which has main folders, which each contain 1 subfolder which in turn contains 1 normal row inside it.
The examples I have found, either contain just 1 folder containing rows (which I can already do), OR, multi level folders which are so complex that I cannot understand them.
Hence why I am looking for an example which has main folders > sub folder > row
Hopefully someone is able to help.
Thank you all in advance for any help you can offer.
Why not simply add code in Expand event to add rows?
They will have right indent.
And you can toggle expanding with list.expanded(row) = true
Christian,
I need main folders, with sub folders, with rows.
I cannot add code to the expand event, as I have no idea what I am doing
and how do you have your data structured?
I used the example single level hierarchical listbox from the Language Reference - but this only shows single level, and I need 2 level.
put a listbox on your window and put this code in open event:
[code] Listbox1.Hierarchical = true
Listbox1.InsertRow 0,“Hello World 1”
Listbox1.InsertRow 1,“Hello World 2”,1
Listbox1.InsertRow 2,“Hello World 3”
Listbox1.InsertRow 3,“Hello World 4”,1
Listbox1.InsertRow 4,“Hello World 5”
[/code]
That fills the hierarchical listbox right away with indent.
You can of course use InsetFolder have the triangle.
Christian,
Thanks but I already have a fully working single level hierarchical listbox - whereby the user clicks on the disclosure triangle in order to display the row.
I need a top level folder, which when expanded, displays a sub folder, which when expanded shows a row.
no, this is two level already!?
The LR example is described as single level hierarchical, therefore I need a 2 level.
If you are saying that a row in a folder, in another folder is 3 levels, then I need a 3 level.
well, make a new project with a listbox and put code in open event:
listbox1.Hierarchical = true
listbox1.AddFolder "Hello"
listbox1.Expanded(Listbox1.LastIndex) = true
than add an ExpandRow event to the listbox with this code:
me.AddRow "Hello World"
run it and you see a listbox with two levels, the folder and the item inside.
Christian,
once again - I already have that.
The Language Reference describes that as SINGLE level?
I need another level. Two folders and a row.
Richard, try this example I just put together in a few seconds. Basically you add another folder in the Expand event, or just add normal rows. You should have a class that describes the data model you are representing in the listbox and it should make this pretty easy.
https://www.dropbox.com/s/zkp24ppu3i0vi1u/expand%20row%20listbox.xojo_binary_project?dl=0
Thanks Jason.
I will take a look after a cup of tea. This is giving me a real headache
Richard, have you looked at the FileBrowser example that comes with Xojo. You can find it along the path Desktop/Controls/Listbox/FileBrowser.xojo_binary_project. It allows you to browse the contents of a hard drive. I quite after getting about 10 levels deep. If you can’t figure it out with that example you may never figure it out.