Bob Butler
9/29/2011 12:42:00 PM
"Phil Hunt" <aaa@aaa.com> wrote in message
news:j60602$ak4$1@speranza.aioe.org...
> How do I disable an user control. It looks like I have to call a function
> in the user control to do that. Why ? I can set the .Visible but I don't
> even see the .Enabled property
>
> TIA
Start a new project, add a user control, then add a command button and the
control to the form. Put this in the form:
Private Sub cmdCommand1_Click()
UserControl11.Enabled = Not UserControl11.Enabled
End Sub
Put this in the user control and try changing the Enabled property for the
control in the IDE and after running the project.
Private mbEnabled As Boolean
Private Sub UserControl_InitProperties()
mbEnabled = True
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
mbEnabled = PropBag.ReadProperty("Enabled", True)
ShowEnabledState
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "Enabled", mbEnabled
End Sub
Public Property Get Enabled() As Boolean
Enabled = mbEnabled
End Property
Public Property Let Enabled(ByVal NewState As Boolean)
mbEnabled = NewState
ShowEnabledState
End Property
Private Sub ShowEnabledState()
UserControl.BackColor = IIf(mbEnabled, vbWhite, vbBlack)
End Sub