我正在使用后台工作人员来填充列表视图,但我也想添加子项。谁能帮我吗?
Public Class Form1
Private Sub bgw_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles bgw.DoWork
Dim li As New List(Of ListViewItem)
For Each fn As String In My.Computer.FileSystem.GetFiles("s:\Videos", FileIO.SearchOption.SearchAllSubDirectories, "*.*")
li.Add(New ListViewItem(My.Computer.FileSystem.GetName(fn)))
'here i want to add a subitem containing the filesize
'My.Computer.FileSystem.GetFileInfo(fn).Length
Next
e.Result = li.ToArray
End Sub
Private Sub bgw_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles bgw.RunWorkerCompleted
lv.Items.AddRange(DirectCast(e.Result, ListViewItem()))
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
bgw.RunWorkerAsync()
End Sub
End Class