Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Power of Visual Inheritance in .NET – “Best”

, 4 Dec 2003
This article helps in exploring the power of Visual Inheritance and makes your application development very easy.

Public Class ChildForm
    Inherits FormsInheritance.PMainForm

#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.
    Friend WithEvents BChildForm3 As System.Windows.Forms.Button
    Friend WithEvents BChildForm1 As System.Windows.Forms.Button
    Friend WithEvents BChildForm2 As System.Windows.Forms.Button
    Friend WithEvents BParentForm As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.BChildForm3 = New System.Windows.Forms.Button()
        Me.BChildForm1 = New System.Windows.Forms.Button()
        Me.BChildForm2 = New System.Windows.Forms.Button()
        Me.BParentForm = New System.Windows.Forms.Button()
        Me.NavPanel.SuspendLayout()
        Me.SuspendLayout()
        '
        'BParent
        '
        Me.BParent.Visible = True
        '
        'NavPanel
        '
        Me.NavPanel.Size = New System.Drawing.Size(440, 80)
        Me.NavPanel.Visible = True
        '
        'BChildForm3
        '
        Me.BChildForm3.BackColor = System.Drawing.Color.Silver
        Me.BChildForm3.Location = New System.Drawing.Point(128, 208)
        Me.BChildForm3.Name = "BChildForm3"
        Me.BChildForm3.Size = New System.Drawing.Size(136, 24)
        Me.BChildForm3.TabIndex = 9
        Me.BChildForm3.Text = "Child Form 3"
        '
        'BChildForm1
        '
        Me.BChildForm1.BackColor = System.Drawing.Color.Silver
        Me.BChildForm1.Location = New System.Drawing.Point(128, 144)
        Me.BChildForm1.Name = "BChildForm1"
        Me.BChildForm1.Size = New System.Drawing.Size(136, 24)
        Me.BChildForm1.TabIndex = 8
        Me.BChildForm1.Text = "Child Form 1"
        '
        'BChildForm2
        '
        Me.BChildForm2.BackColor = System.Drawing.Color.Silver
        Me.BChildForm2.Location = New System.Drawing.Point(128, 176)
        Me.BChildForm2.Name = "BChildForm2"
        Me.BChildForm2.Size = New System.Drawing.Size(136, 24)
        Me.BChildForm2.TabIndex = 7
        Me.BChildForm2.Text = "Child Form 2"
        '
        'BParentForm
        '
        Me.BParentForm.BackColor = System.Drawing.Color.Silver
        Me.BParentForm.Location = New System.Drawing.Point(128, 112)
        Me.BParentForm.Name = "BParentForm"
        Me.BParentForm.Size = New System.Drawing.Size(136, 24)
        Me.BParentForm.TabIndex = 10
        Me.BParentForm.Text = "Parent / Base Form"
        '
        'ChildForm
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(440, 266)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.BParentForm, Me.BChildForm3, Me.BChildForm1, Me.BChildForm2, Me.NavPanel})
        Me.Name = "ChildForm"
        Me.Text = "Normal Child Form - Simply Inheriting from the Parent"
        Me.NavPanel.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub BChildForm1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BChildForm1.Click
        Dim NFrmChild1 As New CForm1()
        NFrmChild1.Show()
    End Sub

    Private Sub BChildForm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BChildForm2.Click
        Dim NFrmChild2 As New CForm2()
        NFrmChild2.Show()
    End Sub

    Private Sub BChildForm3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BChildForm3.Click
        Dim NFrmChild3 As New CForm3()
        NFrmChild3.Show()
    End Sub

    Private Sub BParentForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BParentForm.Click
        Dim objParent As New PMainForm()
        objParent.Show()
    End Sub
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Saurabhdotnet
Web Developer
India India
Saurabh Verma works as an Architect, possessing over 10 years designing and developing software and currently assists product companies to scale and writing flexible software. He has vast experience in designing Web 2.0 solutions using Microsoft Technologies; WF, WCF and AJAX.ASP.NET, and practicing AGILE Methodologies and Domain Driven Design for the implementation. He likes to perform superbike stunts in his free time. Smile | :)
 
He has been awarded Microsoft Most Valuable Professional, MCSD.NET, MCAD.NET, MCDBA and Microsoft Web Rock Star 2007.
 
He maintains his blog at http://www.domaindrivendesign.info for all the aspiring architects and developers.
 
You can reach him at saurabhdotnet@hotmail.com

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141216.1 | Last Updated 5 Dec 2003
Article Copyright 2003 by Saurabhdotnet
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid