Click here to Skip to main content
15,891,248 members
Articles / Mobile Apps / Windows Mobile

Power of Visual Inheritance in .NET – “Best”

Rate me:
Please Sign up or sign in to vote.
3.58/5 (25 votes)
4 Dec 20039 min read 80.5K   630   39  
This article helps in exploring the power of Visual Inheritance and makes your application development very easy.

Public Class CForm3
    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 Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.NavPanel.SuspendLayout()
        Me.SuspendLayout()
        '
        'BParent
        '
        Me.BParent.Location = New System.Drawing.Point(192, 16)
        Me.BParent.Size = New System.Drawing.Size(80, 56)
        Me.BParent.Text = "Parent changed from Child"
        Me.BParent.Visible = True
        '
        'NavPanel
        '
        Me.NavPanel.Visible = True
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.Color.IndianRed
        Me.Label1.Location = New System.Drawing.Point(104, 168)
        Me.Label1.Name = "Label1"
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "Label1"
        '
        'CForm3
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.NavPanel, Me.Label1})
        Me.Name = "CForm3"
        Me.Text = "Child Form 3"
        Me.NavPanel.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub CForm3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.InfoLabel = Label1
        Me.Position = 99
    End Sub


    'Overiding the implementation of the Parent Form
    'please don't forget to remove the handles keyword from the last while
    'implementing in the child form
    Protected Friend Shadows Sub BParent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MsgBox("Functionality of Child is used.")
    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


Written By
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

Comments and Discussions