Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleGive an ActiveX control a caption property that is also its default
Keywordsdefault, caption, ActiveX, property
CategoriesTips and Tricks, ActiveX
 
A control's default property the value you get or set when you use the control without specifying a property. Its "caption property" is immediately displayed without waiting for you to press Enter when you type in the Properties window at design time.

You set both of these properties by assigning a special procedure ID to the properties using the Procedure Attributes method. Unfortunately a property can only have one procedure ID at a time so you cannot make the same property both the "caption property" and the default property.

To work around this, create a hidden property. You can give iy ant name because the the user will never see it. Double click the control to open it. Select the Tools menu's Procedure Attributes item and click the Advanced button to show this dialog. In the Name dropdown, select the property you want to use. In the Procedure ID dropdown, select "(Default)." Check the "Hide this member" box so the property doesn't appear in the Properties window.

Now select the real property you want to use as the caption property. In the Procedure ID dropdown, select "Caption" and click OK.

Now delegate the hidden property to the property you just assigned as the caption property. The following code shows how you might delegate the HiddenDefault property to the TheCaption property.

 
' Delegate this property to TheCaption.
Public Property Get HiddenDefault() As Variant
    HiddenDefault = TheCaption
End Property

' Delegate this property to TheCaption.
Public Property Let HiddenDefault(ByVal New_HiddenDefault _
    As Variant)
    TheCaption = New_HiddenDefault
    PropertyChanged "TheCaption"
End Property
 
Now when the system needs to use the caption property, it uses TheCaption. When it needs to use the default property, it uses HiddenDefault which delegates to TheCaption.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated