Hierarchical Listbox Disclosure Triangle / Icon Position

Is it possible to have this displayed (and functional) on the far right of a listbox instead of on the left?

not using the inbuilt listbox control

I haven’t done this recently, maybe it doesn’t work anymore, but the trick is to not add folders. Instead always InsertRow with the depth/indent level to create the hierarchy. Even though there’s no folder rows the rows do get indented as specified.

You’ll need to draw the triangle widget and detect it’s click yourself. Build this in a Listbox subclass so you can override the Add/Insert Folder/Row methods and keep track of which rows are your faux folders. To collapse you can call Expanded(row)=false and if your hierarchy is properly indented the rows you’d expect to be removed get removed. To store the triangle state you can override RowTag so it stores both the rows state data and the user supplied RowTag.

Also, I don’t remember if drag reordering works with this fake hierarchy. Pulling up my code it has custom drag reordering but that might be just because there’s custom insertion line drawing.

Thanks for the tip!

Hello Will,

i’am looking for this kind of workaround to change the disclosure triangle icon of the hierarchic listbox.

I have a hierarchic listbox with three insertRow and different indend. The display is ok and look at a normal hierarchic folder without the disclosure triangle.
But it seems not working as described, the fake folder not collapse when i use listbox1.expanded(row)=false, in fact the expanded method of the list is not fired too.

Maybe i forgot something.
somebody has try method with success ?

Thanks

You must use AddFolder for those events to fire.

Yes but if you use AddFolder you have the disclosure triangle. The purpose is not to have this ugly triangle but a nice personel icon.

For those who are interested i figure it out with a not very beautifull but working way :

I use insertRow as mentionned, but in the click function i remove the row and use insertfolder in the same place, do the expand, then remove the folder and insert the row. It’s working because the transformation row to folder to row is too quick so invisible.

the click function of the listbox

if x>= 24+(13*(me.RowTag(row))) and x<=24+(13*me.RowTag(row))+8 then if me.RowPicture(row) = moins then dim text_row as string = me.Cell(row,0) dim intend_row as Integer = me.RowTag(row) Listbox1.RemoveRow(row) // supprime row Listbox1.InsertFolder(row,text_row,intend_row)//ajoute folder Listbox1.Expanded(row)=true//met le folder en expande Listbox1.Expanded(row)=false//collapse le folder Listbox1.RemoveRow(row)//supprimer le folder Listbox1.InsertRow row,text_row,intend_row//ajoute le row Listbox1.RowPicture(row) =croix else dim text_row as string = me.Cell(row,0) dim le_intend as Integer = me.RowTag(row) Listbox1.RemoveRow(row) // supprime row Listbox1.InsertFolder(row,text_row,intend_row)//ajoute folder Listbox1.Expanded(row)=false//met le folder en expande Listbox1.Expanded(row)=true//collapse le folder Listbox1.RemoveRow(row)//supprimer le folder Listbox1.InsertRow row,text_row,intend_row//ajoute le row Listbox1.RowPicture(row) =moins end end