Adding Custom Properties to a Label Control

jtstanish

Newcomer
Joined
Dec 10, 2004
Messages
10
I am using label controls in a program and I need to add custom properties to these controls. Can I add my own properties to Label Controls and set velues for these properties that can be accesses throug the control?

i.e. ControlName.MyProperty = 10
Then later test ... IFControlName.MyProperty = 10 Then ...

I need a code example! Thanks!
 
You can inherit from the control and add your own properties and/or methods like this:

Visual Basic:
Class MyLabel
    Inherits Label

    Private m_MyProperty As Integer

    Public Property MyProperty As Integer

        Get

             Return m_MyProperty

        End Get

        Set(ByVal MyValue As Integer)

             m_MyProperty = MyValue

        End Set

    End Property

End Class
 
How do I place an improved Label on my form

I have used inherit to create a new class based on the Label control. How can I place these controls on my form in design mode?
 
This is how I do it:

1) Make sure that you compiled your project.

2) Right Click on the Windows Forms Tab(or any tab you want your control in),
and click on the Add/Remove Items menu item.

3) In the .Net tab, click browse, and go to the bin folder of your project,
and double click it.

4) Select the name of your control class from the list.

You should now see your control on the bottom of the list in the tab you selected.
 
I Now Have It Working ... Thanks!

I Now Have It Working ... Thanks!
BlackStone said:
This is how I do it:

1) Make sure that you compiled your project.

2) Right Click on the Windows Forms Tab(or any tab you want your control in),
and click on the Add/Remove Items menu item.

3) In the .Net tab, click browse, and go to the bin folder of your project,
and double click it.

4) Select the name of your control class from the list.

You should now see your control on the bottom of the list in the tab you selected.
 
Back
Top