Home arrow VB.Net arrow Page 4 - Everything You Wanted to Know About Forms Inheritance in VB.Net
VB.NET

Everything You Wanted to Know About Forms Inheritance in VB.Net


Learn how to take advantage of Forms Inheritance, while being introduced to certain Object Oriented approaches, in Saurabh's latest article.

Author Info:
By: Saurabh Verma
Rating: 4 stars4 stars4 stars4 stars4 stars / 215
October 29, 2003
TABLE OF CONTENTS:
  1. · Everything You Wanted to Know About Forms Inheritance in VB.Net
  2. · Concept of Inheritance
  3. · Visual Inheritance
  4. · What’s New in This Article
  5. · What's New in This Article, Cont'd
  6. · Conclusion

print this article
SEARCH DEVARTICLES

Everything You Wanted to Know About Forms Inheritance in VB.Net - What’s New in This Article
(Page 4 of 6 )

If you simply inherit the form, you will not be able to change the properties of the Controls which you have placed in the base form. This example covers:

  1. How to inherit the form
  2. How make custom properties
  3. How to use the custom properties from the Child form
  4. How you change the properties of the controls from the parent form, which are not in the parent form (i.e. they are in the Child forms)
  5. How to override the functionality of the Parent form from the Child Form
  6. How to change the properties of the inherited controls at design time (i.e. how to reposition the controls, set different properties, etc.)

1) How to inherit the form

Open the child form and replace the ChildForm’s Inherits line to <name of the parent form> from <System.Windows.Forms.Form>

Base Form:
Public Class PMainForm
    Inherits System.Windows.Forms.Form

Child Forms:
Public Class ChildForm
    Inherits PmainForm

2) How to make custom properties

Open the Parent Form and create a property (having a scope as Protected Friend)

    'CurrentPosition Property
    Dim LPosition As Long
    Protected Property Position() As Long
        Get
            Return LPosition
        End Get
        Set(ByVal Value As Long)
            LPosition = Value
        End Set
    End Property

3) How to use the custom properties from the Child form

Open the child Form. Use Me.<propertyName> to change the property. For example, we are changing the property in the Load event of the child form.

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


blog comments powered by Disqus
VB.NET ARTICLES

- MyClass - Implementing Polymorphism in VB.Net
- Building a News Ticker Using VB.Net
- Everything You Wanted to Know About Forms In...
- Building Assemblies with VB.Net
- Simple VB.NET Notify Icon with Panel Applica...
- Regular Expressions in .NET
- String Encryption With Visual Basic .NET
- Deploying Applications in VB.NET: Part 1/2
- Watching Folder Activity in VB.NET
- Creating A Windows Service in VB.NET
- Implementing The Google Web Service In VB.NET
- Migrating to Visual Basic.NET from Visual Ba...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials