More of a curiosity than anything


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: More of a curiosity than anything

  1. #1
    Michael Culley Guest

    More of a curiosity than anything

    I wanted to create a form that I inherited all forms from, just so I can add
    any functions I might need to all forms at once. I was using this so that
    the MDI form could ask any child form which toolbar buttons should be
    displayed. Originally I created a class called FormBase with just an empty
    constructor in it and inherited from this but the forms designer didn't like
    this. So I removed the class, created a form instead, put in the exact same
    code and it worked. As far as I could tell everything was identical. What
    was the difference?

    --
    Michael Culley
    www.vbdotcom.com





  2. #2
    Phil Weber Guest

    Re: More of a curiosity than anything

    > Originally I created a class called FormBase with just an empty
    > constructor in it and inherited from this but the forms designer
    > didn't like this. So I removed the class, created a form instead,
    > put in the exact same code and it worked.


    Michael: Did your FormBase class inherit System.Windows.Forms.Form?
    --
    Phil Weber



  3. #3
    Michael Culley Guest

    Re: More of a curiosity than anything

    Yep, forgot to mention that. It definately inherited from Form because I
    remember the icon changing from a class icon to a form icon.

    --
    Michael Culley
    www.vbdotcom.com


    "Phil Weber" <pweber@nospam.fawcette.com> wrote in message
    news:3dbde748$1@tnews.web.devx.com...
    > > Originally I created a class called FormBase with just an empty
    > > constructor in it and inherited from this but the forms designer
    > > didn't like this. So I removed the class, created a form instead,
    > > put in the exact same code and it worked.

    >
    > Michael: Did your FormBase class inherit System.Windows.Forms.Form?
    > --
    > Phil Weber
    >
    >




  4. #4
    Larry Serflaten Guest

    Re: More of a curiosity than anything

    "Michael Culley" <mculley@NOSPAMoptushome.com.au> wrote
    > So I removed the class, created a form instead, put in the exact same
    > code and it worked. As far as I could tell everything was identical. What
    > was the difference?


    Can you provide a small example? I tried inheriting a form real early on
    (To give all forms an AutoRedraw property) and did not see the problem
    you describe.

    LFS




  5. #5
    Rune Bivrin Guest

    Re: More of a curiosity than anything

    "Michael Culley" <mculley@NOSPAMoptushome.com.au> wrote in
    news:3dbe2f86@tnews.web.devx.com:

    > The code I used was just
    >
    > Public Class FormBase
    > Inherits System.Windows.Forms.Form
    > End Class
    >
    > If I create this as a form I can inherit from it, as a class I can't,
    > but everything is identical.
    >


    I think it's just a matter of compiling before you try to inherit from it.
    The form editor is a bit picky about that. I've done exactly what you've
    tried.

    --
    Rune Bivrin
    - OOP since 1989
    - SQL Server since 1990
    - VB since 1991


  6. #6
    Michael Culley Guest

    Re: More of a curiosity than anything

    The code I used was just

    Public Class FormBase
    Inherits System.Windows.Forms.Form
    End Class

    If I create this as a form I can inherit from it, as a class I can't, but
    everything is identical.

    --
    Michael Culley
    www.vbdotcom.com


    "Larry Serflaten" <serflaten@usinternet.com> wrote in message
    news:3dbe0851$1@tnews.web.devx.com...
    > "Michael Culley" <mculley@NOSPAMoptushome.com.au> wrote
    > > So I removed the class, created a form instead, put in the exact same
    > > code and it worked. As far as I could tell everything was identical.

    What
    > > was the difference?

    >
    > Can you provide a small example? I tried inheriting a form real early on
    > (To give all forms an AutoRedraw property) and did not see the problem
    > you describe.
    >
    > LFS
    >
    >
    >




  7. #7
    Michael Culley Guest

    Re: More of a curiosity than anything

    I tried compiling and it compiled without an error but I still couldn't
    inherit from the class. Its no big deal, it works if I create it as a form,
    I'm just curious as to what is going on.

    --
    Michael Culley
    www.vbdotcom.com


    "Rune Bivrin" <rune@bivrin.com> wrote in message
    news:Xns92B656ACFB419runebivrincom@209.1.14.29...
    > "Michael Culley" <mculley@NOSPAMoptushome.com.au> wrote in
    > news:3dbe2f86@tnews.web.devx.com:
    >
    > > The code I used was just
    > >
    > > Public Class FormBase
    > > Inherits System.Windows.Forms.Form
    > > End Class
    > >
    > > If I create this as a form I can inherit from it, as a class I can't,
    > > but everything is identical.
    > >

    >
    > I think it's just a matter of compiling before you try to inherit from it.
    > The form editor is a bit picky about that. I've done exactly what you've
    > tried.
    >
    > --
    > Rune Bivrin
    > - OOP since 1989
    > - SQL Server since 1990
    > - VB since 1991
    >




  8. #8
    Larry Serflaten Guest

    Re: More of a curiosity than anything

    "Michael Culley" <mculley@NOSPAMoptushome.com.au> wrote
    > I tried compiling and it compiled without an error but I still couldn't
    > inherit from the class. Its no big deal, it works if I create it as a form,
    > I'm just curious as to what is going on.


    A couple things to check;

    For your base form project, go to Project properties and check or change
    the Root namespace, and that the Output Type is set to Class Library.
    Compile the project.

    In your derived project, add a reference to your base DLL file via the
    ..Net components tab (I don't know that the tab makes a difference, but...)
    On your Inherits line, start with the root namespace which should give you
    intellisense all the way out to your base form.

    (A Root name can be partitioned: Company.Product.Tool.XXX where
    the text in the Root textbox will end at Tool and XXX will be the name
    of your base project, )

    Can you use your class library now?

    LFS






  9. #9
    Michael Culley Guest

    Re: More of a curiosity than anything

    Hi Larry,

    They are both in the same project. Its no big deal, if a create it as a
    class I cannot inherit from it, if I create the exact same code as a form I
    can, I'm just curious as to why.

    --
    Michael Culley
    www.vbdotcom.com



  10. #10
    Paul Mc Guest

    Re: More of a curiosity than anything


    G'day Michael.

    Take a look at your .vbproj file in a text editor. You will see a section
    called <Files>. Each file in your project should be represented here. You
    will notice that each file has a "subtype" element; most will be either
    SubType = "Code"
    or
    SubType = "Form".

    The IDE behaves slightly differently with each file depending on this subtype
    - the behaviour that you are experiencing probably stems from this...

    Cheers,
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center