jtstanish Posted December 25, 2004 Posted December 25, 2004 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! Quote
BlackStone Posted December 25, 2004 Posted December 25, 2004 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 Quote "For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
jtstanish Posted December 26, 2004 Author Posted December 26, 2004 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? Quote
BlackStone Posted December 26, 2004 Posted December 26, 2004 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. Quote "For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
jtstanish Posted December 27, 2004 Author Posted December 27, 2004 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.