ListView - How to update item with changing values

motti100

Member
Joined
Mar 6, 2005
Messages
19
Programming Experience
1-3
Please help.

I have a Listview


Direct Size
=============
c:\test 1000

Size changes constantly.
How do I "update" the item under size (with current value)?

Thanks
 
motti100 said:
Hi

Do you have an answer for both alternatives?

Well, assuming you use the listview in Details view, the size is in the second column and you want to update all items at once:

VB.NET:
Public Sub UpdateSize()
  Dim itemX As ListViewItem
  Dim stringNewSize As String
  For Each itemX In ListView1
	stringNewSize = getNewSize(itemX.Text)
	itemX.SubItems(1) = stringNewSize
  Next
  itemX = Nothing
End Sub

Private Function getNewSize(ByVal FileName As String) As String
  'Put your code here to determine the size of the file
'and don't forget to Return the new size as a string!
End Function

You can then use a Timer to call UpdateSize() on an interval, or call UpdateSize() at the click of a button... whatever you want. I guess this answers for both automatically and programmatically ;)
 
Back
Top