The collaps was missing. This should work: Hierarchical is a subclass of listbox
Project: TeileTest
Date: Sunday, 3 July 2022 12:30:29
HierarchicalListBox
Class HierarchicalListBox
Inherits Desktoplistbox
Constants
Const Leer As String = " "
Events
Sub Opening()
if tblInhalt = NIL then tblInhalt = DB.Table(“tblInhalt”)
#if DebugBuild then
me.ColumnWidths = “60%,10%,10%,10%”
#else
me.ColumnWidths = “100%,0,0,0”
#endif
me.AllowExpandableRows = True
Var myRids() as UInt32 = me.getInhaltRidsNull for i as Integer = 0 to myRids.LastIndex
Var tmp() as UInt32 = me.getChildren(myRids(i)) tblInhalt.RecID = myrids(i)
if tmp.Count > 0 then
var s as string = tblInhalt.VarCharField(“fldTitel”).Value
me.AddExpandableRow(s)
me.cellTextAt(me.LastAddedRowIndex, 1) = str(myRids(i)) me.cellTextAt(me.LastAddedRowIndex, 2) = tblInhalt.VarCharField(“fldETextFile”).Value me.cellTextAt(me.LastAddedRowIndex, 3) = Leer
else
me.AddRow tblInhalt.VarCharField(“fldTitel”).Value me.cellTextAt(me.LastAddedRowIndex, 1) = str(myRids(i)) me.cellTextAt(me.LastAddedRowIndex, 2) = tblInhalt.VarCharField(".fldETextFile").Value me.cellTextAt(me.LastAddedRowIndex, 3) = Leer
end if
next
End Sub
Sub RowCollapsed(row As Integer)
Var myRids() as UInt32
myRids = me.getChildren(val(me.CellTextAt(row, 1))) for i as Integer = row + myrids.count DownTo row+1
me.RemoveRowAt(i) next
End Sub
Sub RowExpanded(row As Integer)
if me.RowExpandedAt(row) = False then return
Var myLeer as string = me.cellTextAt(row, 3) me.AllowExpandableRows = True
Var myRids() as UInt32
myRids = me.getChildren(val(me.CellTextAt(row, 1))) for i as Integer = 1 to myRids.count
tblInhalt.RecID = myRids(i-1)
Var tmp() as UInt32 = getChildren(myRids(i-1)) if tmp.count > 0 then
varsasstring= tblInhalt.VarCharField(“fldTitel”).Value me.AddExpandableRowAt(row+i, Leer + myLeer + s) me.cellTextAt(row+i, 1) = str(myRids(i-1))
me.cellTextAt(row+i, 2) = tblInhalt.VarCharField(“fldETextFile”).Value me.cellTextAt(row+i, 3) = Leer + myLeer
else
var s as string = tblInhalt.VarCharField(“fldTitel”).Value me.AddRowAt(row+i, Leer + myLeer + s)
me.cellTextAt(row+i, 1) = str(myRids(i-1))
me.cellTextAt(row+i, 2) = tblInhalt.VarCharField(“fldETextFile”).Value
end if next
End Sub
Methods
Function getChildren(ParentRid as UInt32) As UInt32()
Var myRids() as UInt32
Var mySet as VSet
mySet = tblInhalt.ObjectPtrField(“ptrToParent”).FindValue(parentRid) if mySet = NIL then
return myRids else
Var myiter as VSetIterator = mySet.MakeNewIterator Var r as UInt32 = myiter.FirstItem
While r > 0
myRids.Add r
r = myiter.NextItem wend
if r = 0 then return myRids end if
End Function
Function getInhaltRidsNull() As UInt32()
Var myRids() as UInt32
Var mySet as VSet
mySet = tblInhalt.ObjectPtrField(“ptrToParent”).FindNulls if mySet = NIL then
return myRids
else
Var myiter as VSetIterator = mySet.MakeNewIterator
Var r as UInt32 = myiter.FirstItem
While r > 0
myRids.Add r
r = myiter.NextItem
wend
if r = 0 then
return myRids
end if
End Function
Function getParents(
actRid as UInt32) As UInt32()
Var myRids() as UInt32
Var mySet as VSet
mySet = tblInhalt.ObjectPtrField(“RecID”).FindValue(actRid) if mySet = NIL then
return myRids else
Var myiter as VSetIterator = mySet.MakeNewIterator Var r as UInt32 = myiter.FirstItem
While r > 0
myRids.Add r
r = myiter.NextItem wend
if r = 0 then
return myRids
end if
End Function
End Class