0

I have a listview with some single line entries such as...

Sub MakeListView
    ListView1.AddSingleLine("Empty1")
    ListView1.AddSingleLine("Empty2")
    ListView1.AddSingleLine("Empty3")
    ViewPNL.AddView(ListView1, 0, 0, 100%x, 100%y)
End Sub

When the user does a long click on the listview entry, they can choose to load a file using the dialogue library. I have the file load working fine into fd.ChosenName.

I'm looking for a recommendation on how to update or refresh the listview entry to reflect the file name for the file that was loaded.

So if the list were to originally read:

Empty1
Empty2
Empty3

After loading files into the positions it may read for example:

Picture 1.Jpg
My Document.Doc
Sound File.mp3

I should also add that the user may not load a file into all 3 positions at the same time. So the list would need a refresh with each individual file load into the correct position.

Tony Moreira
  • 93
  • 3
  • 18

1 Answers1

1

Try writing a sub called updateList that clears the list and then rewrites everything. It is instantaneous. Call the sub when you create the activity and then again whenever a file is selected.

Sub updateList
ListView1.Clear
If filename <> "" Then
ListView1.AddSingleLine(filename)
Else
ListView1.AddSingleLine("Empty")
End If
End Sub
jb11
  • 557
  • 5
  • 18
  • Thanks - this is definitely a step in the right direction. Is there a simple way, however, I'm wondering - to update only the particular position where the file was loaded. The code you gave works great - but eliminates the remainder of the list. So if I have originally added for example three lines using ListView1.AddSingleLine("Empty") 3 times, after loading the file the update works great but only shows one line with the filename and always defaults to the first position, even if the second position was where a file was loaded. – Tony Moreira Dec 01 '11 at 13:30
  • You can modify the code so it checks conditionally tor each file and draws it. Just add any other lines above or below the if statement. As far as I'm aware you can't update or insert into a list – jb11 Dec 01 '11 at 22:23
  • Thanks I've started heading in that direction - still learning a few things such as lists along the way. Not a whole lot of experience with maps either - bit I'm wondering if reading and writing to a map with each file load would do the trick as when the app quits - I want the files that were loaded during use to be reloaded into the positions on app restart anyways. – Tony Moreira Dec 02 '11 at 00:15