stangnut

Hello!

I have a problem which is frustrating me. Why won't the roperties and methods that are inherited from my custom user control work on my Win Form

I have declared the properties and methods as Public and Intellisense "sees" the property if I call it from the Form. But, the frustrating part is that the property does not work. It is a simple property that changes the string value of the text on a label. The label's container is a ToolStrip. Here's the property:

Public Property DisplayApplicationStatus() As String

Get

Return Me.label1.Text

End Get

Set(ByVal value As String)

Me.label1.Text = value

End Set

End Property

As I stated earlier, VB.NET "sees" this property (I can pull it up with Intellisense) but I cannot change the text of the label. I want the label to display "Ready" or other text.

objAppStatus.DisplayApplicationStatus = "Ready"



Re: Windows Forms General Question about accessing properties, methods from a user control

nobugz

Change your code to this:

objAppStatus.DisplayApplicationStatus = "Ready"
objAppStatus.Show()

If you now see a second form, you've got a problem with your objAppStatus reference initialization.







Re: Windows Forms General Question about accessing properties, methods from a user control

stangnut

Thanks, nobugz, for replying!

I will try that out, now.





Re: Windows Forms General Question about accessing properties, methods from a user control

stangnut

I did as you requested. Another form does not show up and the label text has not changed. Any suggestions

Thanks!





Re: Windows Forms General Question about accessing properties, methods from a user control

nobugz

There are not a lot of other reasons I can think of if you're sure you are referencing the correct form instance. Perhaps the label is not visible, overlapped by another control or beyond the bounds of the form's client size...





Re: Windows Forms General Question about accessing properties, methods from a user control

stangnut

I have double checked and verified that I am referencing the correct project and form. The form is a User Control from another project in my Solution. The User Control contains a ToolStrip. The ToolStrip contains a few labels and a progress bar. One of the labels (I listed it as Label1) will be used to display the status of the application, such as "Ready" (This is where the DisplayApplicationStatus property should kick in). The ToolStrip is set to Autosize = true, so I do physically see the ToolStrip.

Also, it was working before in another application and I have no idea what may have caused it to not work in this current one(I am still somewhat of a noob ) I baffled because, as I stated, Intellisense kicks in for the property. Strange. I do not know what to do

Thanks!





Re: Windows Forms General Question about accessing properties, methods from a user control

nobugz

Okay, objAppStatus is actually a UserControl. Show() wouldn't make any difference. "objAppStatus" is a pretty unusual name for a UserControl instance. What did you name the UserControl after you dropped in on the form We also really need to see more code than the one line you gave us, where you got the "objAppStatus" reference is critical to this problem.





Re: Windows Forms General Question about accessing properties, methods from a user control

stangnut

Thanks, nobugz! You are da man!

I am not ashamed to say that I guess I did not know what I was doing when I declare my variable for the UserControl. Maybe that was overkill. To my understanding ,here is what may have happened:

  • I dropped an instance of the UserControl, which is named AppStatus, on the form and left the default name that VB gave it - AppStatus1
  • objAppStatus was the variable I used as a member of the my UserControl -

    Private objAppStatus As New AppStatus

    When I used the member, objAppStatus to access the DisplayApplicationStatus property, the property would not work.
  • After reading your last post, the light went off and I used the actual instance of the control on my form, namely, AppStatus1 to access the property and it worked! -

    Me.AppStatus1.DisplayApplicationStatus = "testing"

Was VB trying to tell me that my objAppStatus member was correct and it could access the property, but I had more than one instance and that is why the property code did not work

Thanks, again! I hope any other coding or form design issues will have an easy resolution such as the one you provided!

-stangut





Re: Windows Forms General Question about accessing properties, methods from a user control

nobugz

You've got it! Congrats. Does it make sense now





Re: Windows Forms General Question about accessing properties, methods from a user control

stangnut

Yes, it does. I guess I was thinking or digging too deep and it was right in front of me.

Thanks, again!