开发者

vb.net - backgroundworker & listview.items.add()

开发者 https://www.devze.com 2023-01-15 11:27 出处:网络
I\'m using a vb.net backgroundworker thread for processing and I need to periodically add items to a listview (with multiple columns) during the thread processing.

I'm using a vb.net backgroundworker thread for processing and I need to periodically add items to a listview (with multiple columns) during the thread processing.

I can easily use the following code for delegating the task to add an item to a listview, but I can't figure out how to additional info to other columns on the same row.

Anyone help me?

In the thread, I'd execute the following to trigger the invoke to add to listview:

AddListItem(ListView1, filepath)

Here is the delegate code, if someone can show me how to add the text2 to a 2nd column I'd appreciate it HUGE:

Delegate Sub AddListItem_Delegate(ByVal [Label] As ListView, ByVal [text] As String)
Private Sub AddListItem(ByVal [ListView] As List开发者_运维知识库View, ByVal [text] As String, Optional ByVal [text2] As String = "")
    If [ListView].InvokeRequired Then
        Dim MyDelegate As New AddListItem_Delegate(AddressOf AddListItem)
        Me.Invoke(MyDelegate, New Object() {[ListView], [text]})
    Else
        ListView1.Items.Add([text])
    End If
End Sub


Create ListViewItems explicitly as shown here with all necessary subitems and use ListViewItemCollection.Add overload that accepts ListViewItem as arguments.

0

精彩评论

暂无评论...
验证码 换一张
取 消