1

Possible Duplicate:
Text property in a UserControl in C#

I'm creating a UserControl that I would like to be available to another development group as a sort of "black box" widget.

As such, I would like all of the major properties to be accessible and editable from the 'Properties' window during design time.

Each of my properties is tagged like this:

<Category("Foo"), _
    Description("The Foo of this Fubar"), _
    Browsable(True)> _
    Property Example() As Baz

And is successfully displayed in the 'Properties' window. I have one property, however, that is overriding the 'Text' property of UserControl so that the other developers should be able to edit the Text of my control, and have it edit the displayed Text of a label on the UserControl. The code looks like this:

        <Category("Appearance"), _
    Description("Text to be displayed on StatusWidget"), _
    Browsable(True)> _
    Overrides Property Text() As String
        Get
            Return sText
        End Get
        Set(ByVal Value As String)
            sText = Value
            TextBlock.Text = sText
        End Set
    End Property

This works fine when called in the VB code of an external project like this:

StatusWidget1.Text = "My Goddang Text"

But does not automatically update when a string is typed into the 'Text' field of the 'Properties' window.

Attempts to correct this with a call like this Me.Label1.Text = Me.Text in the "InitializeComponent()" method are unsuccessful.

So finally, my question: Is there any way to update the properties of the Controls that are present on a UserControl from the 'Properties' window, such that they are available immediately during run?

Community
  • 1
  • 1
rfinz
  • 372
  • 6
  • 14

0 Answers0