Using MustInerit with Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nate axtell

    Using MustInerit with Forms

    Using VB.NET 2003 in Visual Studio...
    I have created a base Form class ProjectA.FormA, that I inherit in another
    class called ProjectB.FormB. FormA is declared as MustInherit. When I try
    to view the inheriting class FormB in the Visual Studio Designer I see the
    error:
    "The designer must create and instance of 'ProjectA.FormA ' but it cannot
    because the type is declared as abstract."
    If I remove the MustInherit and rebuild ProjectA then FormB is displayed
    without the error. Has anyone found a way to use MustInherit in a base
    class definition and then view the inheriting forms in the designer?
    thanks,
    nate


  • Herfried K. Wagner [MVP]

    #2
    Re: Using MustInerit with Forms

    "nate axtell" <naxtell at progeny dot net> schrieb:[color=blue]
    > I have created a base Form class ProjectA.FormA, that I inherit in another
    > class called ProjectB.FormB. FormA is declared as MustInherit. When I
    > try to view the inheriting class FormB in the Visual Studio Designer I see
    > the error:
    > "The designer must create and instance of 'ProjectA.FormA ' but it cannot
    > because the type is declared as abstract."
    > If I remove the MustInherit and rebuild ProjectA then FormB is displayed
    > without the error. Has anyone found a way to use MustInherit in a base
    > class definition and then view the inheriting forms in the designer?[/color]

    That's a known limitation of the designer. You can partially work around it
    by using this code:

    \\\

    ' In the project properties the checkbox that defines the
    ' 'DEBUG' constant must be checked.
    #If DEBUG Then
    Public Class Foo
    #Else
    Public MustInherit Class Foo
    #End If
    ...
    End Class
    ///

    In release mode the class will be 'MustInherit'.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    Comment

    • nate axtell

      #3
      Re: Using MustInerit with Forms

      Thanks. I'll try it out.
      [color=blue]
      > That's a known limitation of the designer. You can partially work around
      > it by using this code:
      >
      > \\\
      >
      > ' In the project properties the checkbox that defines the
      > ' 'DEBUG' constant must be checked.
      > #If DEBUG Then
      > Public Class Foo
      > #Else
      > Public MustInherit Class Foo
      > #End If
      > ...
      > End Class
      > ///
      >
      > In release mode the class will be 'MustInherit'.
      >
      > --
      > M S Herfried K. Wagner
      > M V P <URL:http://dotnet.mvps.org/>
      > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>[/color]


      Comment

      Working...