how can i define a defult property to my active-x control?
Printable View
how can i define a defult property to my active-x control?
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.
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