Visual Inheritance - Yes or No ?

  • Thread starter Thread starter Dino Buljubasic
  • Start date Start date
D

Dino Buljubasic

I am using VS 2005 (C#) and I am considering using Visual Inheritance.

I have heard about some problems with it, such as controls
dissapearing and would like to know from people who have experience
with Visual Inheritance what do they have to say about it.

Any ideas, suggestions, concerns, tips, hints?

Thank you,
_dino_
 
Hi Dino,

We use VI on forms extensively in VS 2003.
I'd definitely recommend using it. Dunno about problems in VS 2005
(seems OK so far) but in VS 2003 AFAIKS there's one problem which might
cause problems when you're loading an inherited form.
To avoid this problem make sure you

1) use Me.DesignMode as appropriate.

Your client code in event handlers or overrides should
probably not be executed during design mode.

2) Use overrides rather than the event handlers.

So for ex. in VB I'd use:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

rather than

Private Sub ManagedForm_Load(...) Handles MyBase.Load

3) Make handlers overridable so you can override them in derived forms. For
ex:

Private Sub btnOk_Click(...) Handles btnOk.Click
OnOkClick()
End Sub

Protected Overridable Sub OnOkClick()
End Sub


4) Oh, and of course, use a version control system or have backups handy ;-)

HTH & Regards,
Marius.
 
Hi Dino,

I've had some problems with visual inheritance and localization as I
describe in 'Problem with localizing inherited form'
(Apart from that, visual has
worked fine for me, at least in VS2003, which I have been using mostly so
far.

Regards,
Markus Hjärne
 
Back
Top