Hi Team,
I am doing a automation software for book publishing industry.
I am struck on accessing main form label in another class. I want to display the status in the ToolStripStatusLabel1.
I have one main form and one external class with shared method. While button clicks on the main form, the external class is initiated. And i would like to display the status/progress information to the main form ToolStripStatusLabel1.
I used multithreading, form accessing objects, its executed fine, but no updation in the MainForm Label control (ToolStripStatusLabel1.).
What I have tried:
METHOD1:
MainForm.ShowTextLabel("Importing XML...")
Public Sub ShowTextLabel(ByVal Str As String)
For Each f As Form In My.Application.OpenForms
If f.InvokeRequired Then
If f.Tag = "main" Then
Dim fcast As New MainForm
fcast = f
fcast.lblStatus.Text = Str
End If
End If
Next
End Sub
METHOD2:
Dim F1 = New MainForm
F1.ToolStripStatusLabel1.Text = "Importing XML..."
F1.lblStatus.Text = "Importing XML..."
Application.DoEvents()
F1.ShowAlert()
Public Sub ShowAlert()
Dim objNewThread1 As New Thread(AddressOf StartShowAlertText)
objNewThread1.IsBackground = True
objNewThread1.Start()
End Sub
Public Delegate Sub SetText1(text As String)
Public Sub StartShowAlertText()
While True
ToolStripStatusLabel1.Text = "Importing XML..."
If lblStatus.InvokeRequired Then
lblStatus.Invoke(New MethodInvoker(Sub() lblStatus.Text = "Importing..."))
Else
lblStatus.Text = "Importing..."
lblStatus.Refresh()
End If
Application.DoEvents()
Thread.Sleep(2000)
End While
End Sub
METHOD3:
Dim Cls1 As New
Cls1.ChangeText()
Public Class VBControls
Dim callingForm As CS6_SPinDesignXMLAutoflow
Public Sub ChangeText()
callingForm.lblStatus.Text = "1"
callingForm.lblStatus.Text = "KJjhdfjdsjfhkjds"
Application.DoEvents()
End Sub
End Class
'----------------------------
No Use on the three methods.
Please help me on this issue or provide any valid links on guiding me.
Thanks in advance.
Venkadesh R.