BlakeMcKenna
asked on
Can't reference a control added to a form?
I have a Public SubProcedure in which I pass a Form, a StatusStrip and a String variable. What I'm trying to do is attach the StatusStrip to the Form and it won't let me. Here is my code below.
Public Sub ProcessMessages(ByVal frm As Form, ByVal sbr As StatusStrip, ByVal strMsg As String)
Try
frm.Controls.Add(sbr)
If gblnMessageTimer = True Then
frm.sbr.items(0).text = strMsg
Else
MessageBox.Show(strMsg, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation )
End If
Catch ex As Exception
strErr = "modMain/ProcessMessages() - " & ex.Message
End Try
End Sub
Screenshot.jpg
Public Sub ProcessMessages(ByVal frm As Form, ByVal sbr As StatusStrip, ByVal strMsg As String)
Try
frm.Controls.Add(sbr)
If gblnMessageTimer = True Then
frm.sbr.items(0).text = strMsg
Else
MessageBox.Show(strMsg, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Exclamation
End If
Catch ex As Exception
strErr = "modMain/ProcessMessages()
End Try
End Sub
Screenshot.jpg
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
however, it looks like you already have addressability to the status strip...
try replacing this: frm.sbr.items(0).text = strMsg
with this : sbr.items(0).text = strMsg