[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

James Tyler

9/28/2011 10:10:00 PM

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


7 Answers

Henning

9/29/2011 12:29:00 AM

0


"Phil Hunt" <aaa@aaa.com> skrev i meddelandet
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
>

Using the ActiveX Control Wizard you can add the Enabled Property.

/Henning


Mayayana

9/29/2011 3:12:00 AM

0

I see an Enabled property for a userControl. But in
general I use an Enabled property that I create myself,
because I want to control the item(s) on the control.

The control is basically a form. If I have an RTB on the UC
I create an Enabled property that uses EnableWindow to
activate or deactivate the RTB. Likewise, if I build a button
UC I might have an Enabled property determines the color
of the button and whether it responds to clicks.


--
--
"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
|
|


phil hunt

9/29/2011 11:52:00 AM

0

i only see it at design time, not run time.


"Mayayana" <mayayana@invalid.nospam> wrote in message
news:j60nfl$a87$1@dont-email.me...
> I see an Enabled property for a userControl. But in
> general I use an Enabled property that I create myself,
> because I want to control the item(s) on the control.
>
> The control is basically a form. If I have an RTB on the UC
> I create an Enabled property that uses EnableWindow to
> activate or deactivate the RTB. Likewise, if I build a button
> UC I might have an Enabled property determines the color
> of the button and whether it responds to clicks.
>
>
> --
> --
> "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
> |
> |
>
>


MikeD

9/29/2011 12:32:00 PM

0

You have to write it yourself. The simplest form of doing this would just be
this:

Public Property Let Enabled(ByVal NewValue As Boolean)

UserControl.Enabled = NewValue

End Property

Public Property Get Enabled() As Boolean

Enabled = UserControl.Enabled

End Property


However, that will not cause any constituent controls to appear disabled.
It's just like putting controls in a PictureBox and disabling the
PictureBox. The controls are disabled because their container is disabled,
but they don't have a disabled appearance.

Mike


"phil hunt" <a@abc.com> wrote in message
news:j61m4q$kiq$1@speranza.aioe.org...
> i only see it at design time, not run time.
>
>
> "Mayayana" <mayayana@invalid.nospam> wrote in message
> news:j60nfl$a87$1@dont-email.me...
>> I see an Enabled property for a userControl. But in
>> general I use an Enabled property that I create myself,
>> because I want to control the item(s) on the control.
>>
>> The control is basically a form. If I have an RTB on the UC
>> I create an Enabled property that uses EnableWindow to
>> activate or deactivate the RTB. Likewise, if I build a button
>> UC I might have an Enabled property determines the color
>> of the button and whether it responds to clicks.
>>
>>
>> --
>> --
>> "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
>> |
>> |
>>
>>
>
>

Mayayana

9/29/2011 12:35:00 PM

0

|i only see it at design time, not run time.
|

I see. Sorry. I didn't notice that. I still wonder
why you need it, though. I use several UCs and
all of them have custom Enabled properties that
relate to the controls/windows on the UC. The UC
is a container, like a Form. A Form, also, doesn't
have a runtime Enabled property.




Bob Butler

9/29/2011 12:42:00 PM

0


"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

James Tyler

9/29/2011 1:08:00 PM

0

Thanks, guys.