Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB5,VB6
Expertise: Advanced
Jun 12, 1999

Compound member attributes

The Procedure Attributes dialog includes a Procedure ID combo box, that lets you associate a particular ID to a given member of the class. You usually use this combo to make a property or a method the default item of a class or an ActiveX control, but there are other uses as well. For instance, you may want to associate a Text property to the Text attribute, or a Caption property with the Caption attribute. This is necessary to have these properties behave like they do in standard VB controls: when the user enters a new value in the Property Window, the new value appears immediately in the control, as he or she types each key.

It is not infrequent that you want to combine these attributes with the default ID: if you are writing an enhanced textbox control, for example, its Text property will be also the default property of the control. It is evident that you can't select two IDs for the same property, and you have to resort to the following trick.

Define the Text or Caption property as always, and assign it the corresponding attribute. Then define a new property and make it hidden. This new property - whose name is not really important, because it won't be seen by the user - just delegates to the actual property. For example, you can use a property name that includes a trailing underscore:


Property Get Text_() As String
    Text_ = Text
End Property
Property Let Text_(newValue As String)
    Text = newValue
End Property
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date