Link to home
Start Free TrialLog in
Avatar of BlakeMcKenna
BlakeMcKennaFlag for United States of America

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
Avatar of Ken Butters
Ken Butters
Flag of United States of America image

the statusstrip is being added to the collection of controls, not to the form.
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
ASKER CERTIFIED SOLUTION
Avatar of lludden
lludden
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial