Question re Visual Inheritance in VS 2005

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

Dino Buljubasic

Hi,

I am thinking of using visual inheritance. I am using C# VS 2005. I
am concerned about how good it is. I have heard about problems like
controls dissapearing or so.

Any hints, tips, ideas, concerns ???

Thank you,
_dino_
 
I have not tried Visual Inheritance in VS.NET 2005, mostly because it was
such a pain in the butt in VS.NET 2003. It worked, of course, but I can
personally attest that what you report is true.

Let us know what you find out.

Peter
 
Hi Dino,
I have done this in VS2005 and found I could do everything I wanted except
for inheriting from a generic form i.e.

class MyForm<T> : Form
{
....
}

which causes the derived form to not be able to be rendered in design view,
it works fine at runtime, but not much use unless you intend to create your
form blind. Apparently this is a known issue and not one that MSFT plan to
fix soon.

Mark
 
Hi Peter,

Here is what I got from Markus Groenendijk on this topic. Maybe you
find it useful. I have decided to proceed without visual inheritance.
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.
 
Back
Top