JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Adding Properties to User Controls

Adding properties to user controls is no problem-you just use a Property statement with Get and Set methods. For more details on the Property statement, see "Creating Properties" in Chapter 11.

For example, here's how we added the DisplayColor property to the UserControls example discussed in the In Depth section of this chapter; this property set the background color of the label used in the user control, like this:

    Private LabelColor As Color

    Property DisplayColor() As Color
        Get
            Return LabelColor
        End Get

        Set(ByVal Value As Color)
            LabelColor = Value
            Label1.BackColor = LabelColor
        End Set
    End Property

See the In Depth section of this chapter for more details on the UserControls example.

Related solution:

Found on page:

Creating Properties

508

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor