Overriding Enabled property of the UserControl class 
Author Message
 Overriding Enabled property of the UserControl class

Hi,

I have a custom control derived from UserControl. I'd like to override
Enabled property of  the UserControl so that I can draw my own things on
OnPaint event when the control is in design mode. Everything works just fine
in run-time mode. But I wanna be able to draw  a disabled image when the
user of my control is setting up the properties.

In short, how do I detect changes on Enabled property of the UserControl
class in design mode?

Thanks in advance,



Sat, 13 Nov 2004 14:21:41 GMT  
 Overriding Enabled property of the UserControl class
Mo,

    Basically, you will want to override the OnEnabledChanged method on your
control.  This will be called when the Enabled property is changed.

    Also, there is a DesignMode property on the UserControl that you can use
to tell if your control is being hosted in a designer.

    Hope this helps.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Hi,

> I have a custom control derived from UserControl. I'd like to override
> Enabled property of  the UserControl so that I can draw my own things on
> OnPaint event when the control is in design mode. Everything works just
fine
> in run-time mode. But I wanna be able to draw  a disabled image when the
> user of my control is setting up the properties.

> In short, how do I detect changes on Enabled property of the UserControl
> class in design mode?

> Thanks in advance,



Sat, 13 Nov 2004 21:09:12 GMT  
 Overriding Enabled property of the UserControl class

Thanks for the hint. However, this solution is not working for me as I am trying allow the user of my control to be able to see a disabled picture or text, doesn't matter, when he/she disabled/enabled it.

Basically, when you place the control on a WinForm and disable it, the OnPaint and/or OnEnabledChanged events don't get fired. What I'd like to accomplish is that intercepting EnabledChanged method when the control's Enabled property manipulated via the Properties window. Everything else just works fine.

I guess the question is how to detect the event of changing Enabled property by using Properties window. I also have custom public proeprties on the control. When these props changed via Properties window, OnPaint event get fired, but not for the Enabled property.

Adding the following code didn't solve my problem:
public new bool Enabled

{

set

{

base.Enabled = value;

this.Invalidate();

Quote:
}

get

{

return base.Enabled;

Quote:
}
}

Anymore ideas, please?


Quote:
> Mo,

>     Basically, you will want to override the OnEnabledChanged method on your
> control.  This will be called when the Enabled property is changed.

>     Also, there is a DesignMode property on the UserControl that you can use
> to tell if your control is being hosted in a designer.

>     Hope this helps.

> --
>                - Nicholas Paldino [.NET MVP]



> > Hi,

> > I have a custom control derived from UserControl. I'd like to override
> > Enabled property of  the UserControl so that I can draw my own things on
> > OnPaint event when the control is in design mode. Everything works just
> fine
> > in run-time mode. But I wanna be able to draw  a disabled image when the
> > user of my control is setting up the properties.

> > In short, how do I detect changes on Enabled property of the UserControl
> > class in design mode?

> > Thanks in advance,



Sun, 14 Nov 2004 04:01:10 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to 'enable' overrides for my custom class in Properties Window

2. UserControl-properties...please help

3. Fill Custom Usercontrol property with object list

4. About UserControl's Property

5. Properties in UserControl

6. Hiding Usercontrol Properties

7. New Properties on own UserControl.

8. TextBox inside UserControl DataBinding with DataGrid outside UserControl

9. How to Stop Derived Class from overriding base class method

10. Call to parent class for update UserControl

11. A UserControl is shown as a class..

12. Overriding TextBox.Text property.

 

 
Powered by phpBB® Forum Software