
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