Auto expand a listbox row???

Hi everyone,
after more than a year away, I need to update my app, and the following problem is severely annoying me.

In the FileBrowser project in the Xojo example projects directory, the VolumeBrowserList’s open event has the following code:

[code]Dim f As FolderItem

ColumnCount = 3
ColumnWidths = “55%,30%,15%”

For i As Integer =0 To VolumeCount-1
f = Volume(i)
AddFolder(f.Name)
RowTag(i) = f.GetSaveInfo(GetFolderItem(""))
Next[/code]

I have successfully modified the code so that instead of listing the volumes, it simply lists ONE specific folder (which contains sub folders):

[code]Dim f As FolderItem

Dim i As Integer = 0
f = SpecialFolder.Applications.Child(“Image Files”)
AddFolder(f.Name)
RowTag(i) = f.GetSaveInfo(GetFolderItem(""))[/code]

The problem is, I would like this folder / listbox row automatically expanded.
I have looked at the ExpandRow(0) option, but whatever I do fails :frowning:

Could someone please take a look at the example, and kindly advise me how I get the disclosure triangle to automatically be expanded.

Thank you all in advance.

ExpandRow is correct. What happens exactly when it fails?

Hi Greg,
When I add this line of code to the end of my modified code:

VolumeBrowserList.ExpandRow(0)

I get an error message saying “This item does not exist” VolumeBrowserList.ExpandRow(0)"

My full code looks like this:

[code]Dim f As FolderItem

Dim i As Integer = 0
f = SpecialFolder.Applications.Child(“Image Files”)
AddFolder(f.Name)
RowTag(i) = f.GetSaveInfo(GetFolderItem(""))
VolumeBrowserList.ExpandRow(0)[/code]

    RowTag(i) = f.GetSaveInfo(GetFolderItem(""))
    Expanded(i) = True

Thank you Asis !!! :slight_smile:

[quote=301274:@Richard Summers]Hi Greg,
When I add this line of code to the end of my modified code:

VolumeBrowserList.ExpandRow(0)

I get an error message saying “This item does not exist” VolumeBrowserList.ExpandRow(0)"

My full code looks like this:

[code]Dim f As FolderItem

Dim i As Integer = 0
f = SpecialFolder.Applications.Child(“Image Files”)
AddFolder(f.Name)
RowTag(i) = f.GetSaveInfo(GetFolderItem(""))
VolumeBrowserList.ExpandRow(0)[/code][/quote]
Ah right. ExpandRow is the event name.

I don’t quite follow you Greg?
Are you saying that the VolumeBrowserlist.ExpandRow(0) needs to go in the Expand Row event?

Thanks.

Expanded is correct. See:

http://documentation.xojo.com/index.php/ListBox.Expanded

VolumeBrowserList.Expanded(0) = True

Thanks Kenneth, and thank you everyone - I really appreciate the help :slight_smile:

Don’t use Expanded(0) if you have more than 1 root files. It will expand the first root only.

Thanks Asis, that is fine in my case, as I only have 1 root directory listed :slight_smile:

Then you can remove variable i in your code.

Dim f As FolderItem
f = SpecialFolder.Applications.Child("Image Files")
AddFolder(f.Name)
RowTag(0) = f.GetSaveInfo(GetFolderItem(""))
VolumeBrowserList.Expanded(0)