IDE interferes with Inheritence 
Author Message
 IDE interferes with Inheritence

I have created a controls library with a simple button object, inherited
from a standard (winForm) button. In the constructor of my new button I set
the BackColor property to a non-standard color - say, Ivory.

When referencing this new button in the library, any new button I dump on
the form comes up with an Ivory background, as expected. However, the IDE
generates a line of...

Me.myButton.BackColor = System.Drawing.Color.Ivory

If I subsequently change the color of the button in the controls library, I
would expect the buttons on the form to reflect the new color the next time
the application is run. But because of the specific line in the source code
on the form, the backgound color always comes up Ivory. If I remove that
line manually from the source code - and don't go into design mode in the
IDE to avoid causing the source to be regenerated - then the application
runs as expected, with the background color of the button being determined
by the constructor of the control library in use.

I thought the idea of inheritence was to allow base changes to flow through
to the instantiated objects. Why does the IDE generate this line of code?

Bill



Fri, 10 Sep 2004 18:39:18 GMT  
 IDE interferes with Inheritence
Bill,
Add a System.ComponentModel.DefaultValueAttribute to the control's property
in your controls library.

Imports System.ComponentModel

    <DefaultValue(GetType(System.Drawing.Color), "Ivory")> _
    Public Overrides Property BackColor() as System.Drawing.Color)
        Get
            Return MyBase.BackColor
        End Get
        Set(ByVal Value As System.Drawing.Color)
            MyBase.BackColor = Value
        End Set
    End Property

Unfortunately you need to override the entire property to add the
attribute...

Hope this helps
Jay


Quote:
> I have created a controls library with a simple button object, inherited
> from a standard (winForm) button. In the constructor of my new button I
set
> the BackColor property to a non-standard color - say, Ivory.

> When referencing this new button in the library, any new button I dump on
> the form comes up with an Ivory background, as expected. However, the IDE
> generates a line of...

> Me.myButton.BackColor = System.Drawing.Color.Ivory

> If I subsequently change the color of the button in the controls library,
I
> would expect the buttons on the form to reflect the new color the next
time
> the application is run. But because of the specific line in the source
code
> on the form, the backgound color always comes up Ivory. If I remove that
> line manually from the source code - and don't go into design mode in the
> IDE to avoid causing the source to be regenerated - then the application
> runs as expected, with the background color of the button being determined
> by the constructor of the control library in use.

> I thought the idea of inheritence was to allow base changes to flow
through
> to the instantiated objects. Why does the IDE generate this line of code?

> Bill



Sat, 11 Sep 2004 10:52:50 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. newbie: spaces interfere w/controlling another app?

2. Security interfering with VBA help

3. capture keyboard events without interfering with apps

4. How could I make a moving sprite that doesn't interfere with back ground

5. MaskEdit interfering with my data base?

6. multiple instances of a database wrapper class interfering with each other

7. Screen Savers interfere with loading a form.

8. SSTAB interferes with FORM's MouseMove events

9. main form loading interferes with splash screen!!!

10. SSTAB interferes with FORM's MouseMove events

11. ActiveX inheritence problem

12. Problem with inheritence and localizability

 

 
Powered by phpBB® Forum Software