Re: Abstract Form Class

From: Andrew Bingham (Andrew_at_AndrewBingham.com)
Date: 03/20/04


Date: Sat, 20 Mar 2004 16:20:58 -0000

Unless i misunderstood your question....

Visual inheritance is one of the key benefits of VB.NET.

A form can inherit from another form, and you can call the base form methods
and events (nybase.method) or override them in the subclassed forms, (or do
both of courses)

I have built an application that does exactly this.

-- 
****************************************************************************
andrewbingham.com
tel        01223 514674 (Cambridge)
mobile  07970 161057
fax        07970 601283
email    Andrew@AndrewBingham.com
DISCLAIMER, PLEASE NOTE:
This communication is for the attention of the named recipient only
The content should not be passed on to any other person.
It is sent in good faith, in confidence, and without legal responsibility.
VIRUS CHECK
Emails and attachments are virus checked using Norton® AntiVirus®
2002 which is regularly updated. However  it remains the recipients
responsibility to check emails and attachments sent, or forwarded,
from andrewbingham.com for viruses and macro viruses
****************************************************************************
"Siobhan" <anonymous@discussions.microsoft.com> wrote in message
news:10EBAE9A-D69A-4D3F-8659-CDB0CFAC98E0@microsoft.com...
> 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: Handle Worked - can someone please double check
    ... Ive been searching google with "inheritance" but things come up that I'm not ... the custom class (user control) will appear in your ... to get the _TrimText property somehow. ... Protected Overrides Sub OnLeave ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Windows Service app to access network
    ... Unless overridden, windows ... This system account might have no access to the share. ... Public Sub New ... Protected Overloads Overrides Sub Dispose ...
    (microsoft.public.dotnet.general)
  • Re: Exposing ListItems in Composite Control
    ... End Sub ... > from a listbox control use the following code and ignore the code in the ... > Public Overrides Sub RenderBeginTag(ByVal writer As ... > All you need to do is override the RenderBeginTag and RenderEndTags ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Exposing ListItems in Composite Control
    ... End Sub ... > from a listbox control use the following code and ignore the code in the ... > Public Overrides Sub RenderBeginTag(ByVal writer As ... > All you need to do is override the RenderBeginTag and RenderEndTags ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: Losing SelectedIndex on Custom Listbox postback
    ... But I'm still not retaining the SelectedIndex. ... it overrides RenderContents to force rendering of any ... > Public Sub New ... > Protected Overrides Sub OnLoad ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)