Invoking textbox on UI from another class

  • Thread starter Thread starter randywheeler
  • Start date Start date
R

randywheeler

Guest
I have a public textbox on the main UI that I need to update from another class. I have one class named invokers with the following code.

Public Class Invokers

Delegate Sub SetTextCallback(TB As TextBox, ByVal myText As String)

Public Shared Sub SetText(TB As TextBox, ByVal myText As String)
If TB.InvokeRequired Then
TB.Invoke(New SetTextCallback(AddressOf SetText), New Object() {TB, myText})
Else
TB.AppendText(myText)
End If
End Sub

End Class


Then I have other code in another class that calls the invoke:


Public Class Processing

Invokers.SetText(Form1.tbLog, "Report received from SN " & dataSN & vbCrLf)
Invokers.SetText(Form1.tbLog, "Events " & firstEvent & " to " & lastEvent & " are to be downloaded." & vbCrLf)

End Class



The textbox Form1.tbLog does not update. I am not using threading now, but will be at some point. Any help would be appreciated.

Randy

Continue reading...
 
Back
Top