Deriving from a Base Form

Posted on 2006-05-22
Last Modified: 2010-04-23

Hey, I'm trying to develop a large number of very similar forms (in VB.NET 2005), so I tried to use a base form, which worked great.  Created the one form with all the controls, resize, etc., and created additional classes which derive from this form class.  Very good, very impressed with VB.NET.

Ran into trouble when I tried to add a new control, such as a button, to my derived form.  I go into the designer for my derived form class, and then drop a button on it.  It is visible in the designer, and my class now has the member variable

Friend WithEvents Button2 As System.Windows.Forms.Button

BUT when I show the derived form the buttons do NOT appear.  Do I need to do something special to add a button to a class derived from a base form class??

Question by:riceman0
    LVL 41

    Expert Comment

    Something doesn't sound right...  

    Are you sure you're instantiating the *derived* form (and the not base form, by mistake)?


    Author Comment


    So in other words, what I'm doing should work?  If so I'll look for something I goofed up.
    LVL 41

    Accepted Solution

    I use inherited form a lot... I usually leave a big "blank spot" on the base form where I anticipate that the derived form's controls will go.   You create and save the base form, then create an Inherited Form using the "Add New Item" menu, and picking "inherited form"... that will launch a picklist of all of the possible forms to inherit from.

    So, yeah, it's kinda simple stuff... probably something silly you forgot

    Author Comment


    Okay... glad you clarified.  I was just deriving a plain class from the base form, not an "inherited form."  Probably doesn't generate the partial classes I need... I'll try that.

    Author Comment


    Yeah, that was it.  Thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now