Results 1 to 3 of 3

Thread: defining a defult property for an active-x control

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Location
    israel
    Posts
    19

    defining a defult property for an active-x control

    how can i define a defult property to my active-x control?
    shachar

  2. #2
    Lively Member
    Join Date
    May 2000
    Location
    Antrim
    Posts
    80
    I assume you are using a private variable to return and set your property ie:

    ' private variable to hold enabled property
    Private mblnEnabled as Boolean

    Public Property Get Enabled() As Boolean
    ' return the private variable
    Enabled = mblnEnabled
    ' do stuff
    End Property

    Public Property Let Enabled(NewValue As Boolean)
    ' set the private variable
    mblnEnabled = NewValue
    ' do stuff
    End Property

    If this is the case then you can use the User Control's InitProperties event To populate your private variable with your default value, that way it will be returned to the user on the first Property Get call, ie:

    Private Sub UserControl_InitProperties()
    ' set my default property value
    mblnEnabled = True
    End Sub

    Hope this is of help.

    Best regards,

    Rob Brown.

  3. #3
    New Member
    Join Date
    Jul 2001
    Location
    Regina,Saskatchewan
    Posts
    3
    Another thing you may want to do in your usercontrol is set the default interface property/event. For example for a textbox the default property is .Text and default event is Click().

    To set these, go into the code window for your control and select 'Procedure Attributes' from the 'Tools' menu (this is also where you can specify property descriptions and databinding). Select the property you want to make default from the drop down box and click 'Advanced'. From the attributes frame select 'User Interface Default' and set 'Procedure ID' to '(Default)'. You can specify one default property and one default event.

    I was caught unaware when:

    strTemp = MyTextbox

    caused an error in my project using my first ActiveX control because the text property wasn't made default..... by default.

    David
    Last edited by iamdavid; Jul 31st, 2001 at 08:43 PM.

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