Platforms to show: All Mac Windows Linux Cross-Platform

/Util/FileList/FileList Listbox


Required plugins for this example: MBS Util Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/FileList/FileList Listbox

This example is the version from Thu, 31th Jul 2019.

Project "FileList Listbox.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class WindowRB Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub DoubleClick() dim f as FolderItem f=GetItem(me.ListIndex) if f=nil then MsgBox "no file!?" else dim path as string = f.NativePath MsgBox path end if End EventHandler
EventHandler Sub ExpandRow(row As Integer) dim f as FolderItem f=GetItem(row) if f<>nil then FillList f end if End EventHandler
End Control
EventHandler Sub Open() dim t as integer t=ticks FillList SpecialFolder.Desktop t=ticks-t Title=SpecialFolder.Desktop.name+" "+str(t)+" ticks with Realbasic only" End EventHandler
Protected Sub FillList(f as folderitem) dim list as listbox = self.List dim g as FolderItem dim i,c as integer dim expand(-1) as integer c=f.Count for i=1 to c g=f.TrueItem(i) if g<>Nil then if g.Directory then List.AddFolder g.Name expand.Append List.LastIndex // save indexes to expand later else List.AddRow g.name end if List.CellTag(List.LastIndex,0)=g end if next c=UBound(expand) for i=c downto 0 List.Expanded(expand(i))=true next End Sub
Protected Function GetItem(index as integer) As folderitem dim f as FolderItem dim o as Object if index>=0 and index<=list.ListCount-1 then o=List.CellTag(index,0) if o isa FolderItem then f=FolderItem(o) Return f end if end if End Function
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() windowrb.Show WindowMBS.Show End EventHandler
End Class
Class WindowMBS Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub DoubleClick() dim f as FolderItem f=GetItem(me.ListIndex) if f=nil then MsgBox "no file!?" else dim path as string = f.NativePath MsgBox path end if End EventHandler
EventHandler Sub ExpandRow(row As Integer) dim it as item dim o as Object dim l as FileListMBS o=List.CellTag(row,0) if o isa Item then it=item(o) l=new FileListMBS(it.l,it.index) FillList l end if End EventHandler
End Control
EventHandler Sub Open() dim t as integer t=ticks FillList SpecialFolder.Desktop t=ticks-t Title=SpecialFolder.Desktop.name+" "+str(t)+" ticks with plugin helping" End EventHandler
Protected Sub FillList(l as filelistMBS) dim i,c as integer dim expand(-1) as integer dim it as item c=l.Count-1 for i=0 to c if l.Directory(i) then List.AddFolder l.Name(i) expand.Append List.LastIndex // save indexes to expand later else List.AddRow l.Name(i) end if it=new item it.l=l it.index=i List.CellTag(List.LastIndex,0)=it next c=UBound(expand) for i=c downto 0 List.Expanded(expand(i))=true next End Sub
Protected Sub FillList(f as folderitem) dim l as FileListMBS l=new FileListMBS(f) FillList l End Sub
Protected Function GetItem(index as integer) As folderitem dim o as Object dim it as item if index>=0 and index<=list.ListCount-1 then o=List.CellTag(index,0) if o isa Item then it=item(o) Return it.l.Item(it.index) end if end if End Function
End Class
Class Item
Property index As integer
Property l As FileListMBS
End Class
End Project

See also:

The items on this page are in the following plugins: MBS Util Plugin.


The biggest plugin in space...