Create your Abstract Form base:
--8< ------------------------------------------------
Public MustInherit Class CustomFormBase
Inherits Form
Public MustOverride Property MyColorProperty() As Color
End Class
--8< ------------------------------------------------
Create a Form derived from this Abstract form which knows how to implement
all required properties/methods:
--8< ------------------------------------------------
Public Class CustomForm
Inherits CustomFormBase
Private myColor As Color = Color.Red
Public Overrides Property MyColorProperty() As System.Drawing.Color
Get
Return myColor
End Get
Set(ByVal value As System.Drawing.Color)
myColor = value
End Set
End Property
End Class
--8< ------------------------------------------------
Derive your Main Form from this Form and you will have a happy IDE:
--8< ------------------------------------------------
Public Class MainForm
Inherits CustomForm
End Class
--8< ------------------------------------------------
Mick Doherty
http://dotnetrix.co.uk/form.htm
"DavidGB" <(E-Mail Removed)> wrote in message
news:6AD78F0A-921E-4BC1-A91C-(E-Mail Removed)...
> I have a base form that is used to provide basic graphics, code etc for
> the
> sub forms that the users will see.
>
> In this base form, I want to reference some properties and methods that
> the
> sub forms must implement, so I want to define them as
> Public MustOverride Property ...
>
> When I do this, VS 2008 (correctly) complains that the base form must be
> declared as MustInherit.
>
> However, if I make it MustInherit, I get all kinds of weird errors, for
> example:
> A) None of the subforms can be viewed in the designer. It gives the error:
> "The designer must create an instance of type 'BaseForm' but it cannot
> because the type is declared as abstract"
> B) VS starts to complain that several forms have "inconsistent line
> endings"
>
> Has anyone seen this before, or can anyone suggest what I'm doing wrong?
>
> Thanks
> DavidBGB
>