Inherit from a Windows Form

W

Wu Qinliang

I created a Windows form named myform1, and put some controls on it. I need
another form named myform2. Because myform2 is similar to myform1, so I want
myform2 to inherit from myform1, i.e:

Public Class myform2
inherits myform1
.......

End Class

However the code above can't work. myform2 even can't be displayed in IDE.
I am appreciated for any help.

Wu Qinliang
 
H

Herfried K. Wagner [MVP]

Wu Qinliang said:
I created a Windows form named myform1, and put some controls on it. I need
another form named myform2. Because myform2 is similar to myform1, so I
want
myform2 to inherit from myform1, i.e:

Public Class myform2
inherits myform1
......

End Class

However the code above can't work. myform2 even can't be displayed in IDE.

Choose "Project" -> "Add inherited form..." from VS.NET's menu. Then select
the form to inherit from and add your code to the inherited form.
 
P

Phill. W

Wu Qinliang said:
Because myform2 is similar to myform1, so I want myform2 to
inherit from myform1, i.e: .. . .
However the code above can't work. myform2 even can't be
displayed in IDE.

And what error do you get when you try to open it in the Designer?

Have you marked either the class myform1 or any of its methods as
"MustInherit"? The Designer can't cope with "abstract" forms.

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top