Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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!

Posted

You can inherit from the control and add your own properties and/or methods like this:

 

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

"For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
Posted

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.

"For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
Posted

I Now Have It Working ... Thanks!

 

I Now Have It Working ... Thanks!

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...