Difference between revisions of "ListBox.AddExpandableRow"
From Xojo Documentation
m (→Notes) (Tag: Visual edit) |
|||
Line 36: | Line 36: | ||
===Volume Browser Example=== | ===Volume Browser Example=== | ||
− | The FileBrowser example project displays the file structure of the user's hard disks as a hierarchical ListBox using custom ListBox subclass. The Open event of the custom class builds the hierarchical list using AddExpandableRow in a [[For]] loop for all of the mounted volumes. | + | The FileBrowser example project displays the file structure of the user's hard disks as a hierarchical ListBox using custom ListBox subclass. The Open event of the custom class builds the hierarchical list using AddExpandableRow in a [[For...Next]] loop for all of the mounted volumes. |
You can find this in the Examples folder: Examples/Files/FileBrowser | You can find this in the Examples folder: Examples/Files/FileBrowser | ||
[[Category:API 2.0]] | [[Category:API 2.0]] |
Latest revision as of 16:54, 5 January 2022
Appends text in a new row to the end of the list and adds disclosure triangle only if the AllowExpandableRows property is set to True.
Notes
For multi-column ListBoxes, Item is always assigned to column zero. In the case of hierarchical ListBoxes, AddExpandableRow appends Item to the subitems of the expanded row when called in the ExpandRow event.
Sample Code
The following example adds creates a hierarchical ListBox. Note that AddExpandableRow must be called to create the hierarchical relationship.
Me.ColumnWidths = "150,0"
s1 = "Michigan,Ohio,Minnesota"
sub1 = "Grand Blanc,Bad Axe,Flint,Benton Harbor,"_
+ "Detroit;Cleveland,Columbus,Akron,Pleasantville;St. Paul,Frostbite Falls"
For i As Integer = 1 To s1.Split(",").Count
If NthField(sub1, ";", i) <> "" Then
Me.AddExpandableRow("")
Me.CellValueAt(i - 1, 1) = NthField(sub1, ";", i)
End If
Me.CellValueAt(i - 1, 0) = NthField(s1, ",", i)
Next
Me.ColumnCount = 1
See the section “Hierarchical Listboxes” in the Notes section for illustrations of the ListBox in expanded and collapsed states.
Volume Browser Example
The FileBrowser example project displays the file structure of the user's hard disks as a hierarchical ListBox using custom ListBox subclass. The Open event of the custom class builds the hierarchical list using AddExpandableRow in a For...Next loop for all of the mounted volumes.
You can find this in the Examples folder: Examples/Files/FileBrowser