Abstract Form Class

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Siobhan (anonymous_at_discussions.microsoft.com)
Date: 03/19/04


Date: Fri, 19 Mar 2004 06:56:08 -0800

Hi
I wonder can anyone answer - can I create a form which is an abstract class i.e. has the MustInherits keyword in the class definition

When I do this I get the error message:

'New' cannot be used on a class that is declared 'MustInherit'.

This happens before I have put any other code on the system, all I have done is entered the MustInherits keyword - this is all the code in the form:

Public MustInherit Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container
        Me.Text = "Form1"
    End Sub

#End Region

End Class

I have another form which has more properties and methods etc and I get a similary message:
'New' cannot be used on class 'FormTemplates.frmStandardDataEntry' because it contains a 'MustOverride' member that has not been overridden.

Any help is greatly appreciated!
Thanks
Siobhan



Relevant Pages

  • Re: Abstract Form Class
    ... Visual inheritance is one of the key benefits of VB.NET. ... > This happens before I have put any other code on the system, all I have done is entered the MustInherits keyword - this is all the code in the form:> ... > Public Sub New ... > Protected Overloads Overrides Sub Dispose ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Updating a database via oledb or odbc adapters.
    ... Protected Overloads Overrides Sub Dispose ... 'It can be modified using the Windows Form Designer. ... Friend WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection ...
    (microsoft.public.data.ado)
  • RE: NumericUpDown control
    ... Public Class myNumericUpDown ... Protected Overloads Overrides Sub Dispose ... 'It can be modified using the Windows Form Designer. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Problem with focus on main form after splash screen
    ... Public Class SplashForm ... Protected Overloads Overrides Sub Dispose(ByVal disposing As _ ... 'It can be modified using the Windows Form Designer. ...
    (microsoft.public.dotnet.framework.windowsforms)