Results 1 to 3 of 3

Thread: Inheritance problem

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    6

    Inheritance problem

    Hi,
    I tried to make an application, but had some trouble with the inheritance. I opened a new Windows Form Application Project, added Class1:
    Code:
    Public Class Class1
        Inherits Form
    End Class
    And then added Class2:
    Code:
    Public Class Class2
        Inherits Class1
    End Sub
    But I got an error. Anybody know what's wrong with my code?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Inheritance problem

    First up, if you get an error then please tell us what the error message is.

    As for what you're trying to do, don't just add classes if you're trying to create forms. Forms need a bit of extra work done in the background. To create your first form you should select Add -> Windows Form and then configure it appropriately. To create your second form you should select Add -> New Item. In the Add New Item dialogue you should select the Windows Forms category and then the Inherited Form item. In the Inheritance Picker dialogue you should select your first form from the list as the base class.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    6

    Re: Inheritance problem

    I got this solution, In this solution the Baseform is a class, not a windows Form. But when I added a new class :
    Code:
    Public Class Class1
        Inherits Baseform
    End Class
    It worked out just fine. I'm convinced that the Baseform is a class (the icon looks like a form because it inherited from System.Windows.Forms.Form which was exactly what I did with Class1). I'm sure Baseform was a class because when you comment mark the Inherits ...... line, the icon turns to a class icon.

    The error is:
    The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: Class2 --- The base class 'WindowsApplication1.Class1' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width