I have looked and looked but something is just not clicking. I'm running a simple tcp server in the background and want to update a datagrid with the incoming information. The server is working, but I cannot get the UI grid updated.
I set up the background worker and in the server sub I have reportprogress. The msgbox you see pops up and has the correct text in it, but the grid is not updating. I thought that could be assessed in this progress changed function. What am I missing?Code:Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.Show() BackgroundWorker1.RunWorkerAsync() End Sub Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork BackgroundWorker1.WorkerReportsProgress = True Main() End Sub Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged Dim D(20) As String Dim ReceivedLine As String ReceivedLine = CType(e.UserState, String) MsgBox(ReceivedLine) ' This comes up and gives me the correct text D = ReceivedLine.Split("~") Try Me.MainGrid.Rows.Add(D(0), D(1), D(2), D(3)) ' nothing is added to the grid. I did an add in form_load and it works. Catch ex As Exception MsgBox(ex.Message) End Try End Sub
Thanks




Reply With Quote