Results 1 to 2 of 2

Thread: UserControl Default Property

  1. #1

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    UserControl Default Property

    I have this code for a UserControl called fnd. What I want is to make the ContactNumber property the default property. For example, with a textbox called txt you can do vMyText = txt and it returns the default Text property. How do I make ContactNumber the default?

    VB Code:
    1. Option Explicit
    2.  
    3. Private mvContactNumber
    4.  
    5. Public Property Get ContactNumber() As Long
    6.   ContactNumber = mvContactNumber
    7. End Property
    8.  
    9. Public Property Let ContactNumber(ByVal pContactNumber As Long)
    10.   If pContactNumber > 0 Then
    11.     UserControl.PropertyChanged ContactNumber
    12.     txt.Text = pContactNumber
    13.   End If
    14. End Property
    15.  
    16. Private Sub txt_Change()
    17.   With txt
    18.   If .Text = Val(.Text) Then
    19.     mvContactNumber = .Text
    20.   Else
    21.     mvContactNumber = 0
    22.   End If
    23. End Sub
    24.  
    25. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    26.   ContactNumber = PropBag.ReadProperty("ContactNumber", 0)
    27. End Sub
    28.  
    29. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    30.   PropBag.WriteProperty "ContactNumber", ContactNumber, 0
    31. End Sub
    This world is not my home. I'm just passing through.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: UserControl Default Property

    Click somewhere in your property get/set procedures, and go to Tools->Procedure Attributes. Click Advanced, somewhere in there is a box called Procedure ID, in there select (Default).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width