Error using invoke to update a listview

Asked

Viewed 29 times

0

I have a thread that calls a method that does "Invoke" in listview, only this method only works with a parameter, I need q it accept 3.

my method:

Private Sub Updatelv(ByVal usuarios As String, ByVal status As String, ByVal datahoraAtual As String)
    If Me.InvokeRequired Then
        Dim args() As String = {usuarios, status, datahoraAtual}

 ## Cabeçalhos ##Me.Invoke(New Action(Of String)(AddressOf Updatelv), args)
        Return
    End If
    Me.lstvDados.Items.Add(New ListViewItem(New String() {usuarios, status, datahoraAtual}))
End Sub

1 answer

0

got :) :

Private Delegate Sub ListViewAddItem_delegate(ByVal destinataio As String, ByVal status As String, ByVal hora As String)

Private Sub ListViewAddItem(ByVal destinataio As String, ByVal status As String, ByVal hora As String)
    If Me.lstvDados.InvokeRequired Then
        Dim d As New ListViewAddItem_delegate(AddressOf ListViewAddItem)
        Me.lstvDados.BeginInvoke(d, {destinataio, status, hora})
    Else
        Dim lvi As New ListViewItem(destinataio)
        lvi.SubItems.Add(status)
        lvi.SubItems.Add(hora)
        lstvDados.Items.AddRange(New ListViewItem() {lvi})
        lstvDados.Update()
    End If
End Sub

Browser other questions tagged

You are not signed in. Login or sign up in order to post.