why do I need System.ComponentModel.Component?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: why do I need System.ComponentModel.Component?

  1. #1
    Mitch Abaza Guest

    why do I need System.ComponentModel.Component?

    Anytime I create a ClassLibrary solution in VB.NET, the class created by the
    IDE defaults to inherit System.ComponentModel.Component. Why is this?

    If every class must inherit System.ComponentModel.Component and each class
    is limited to just one base class, how am I supposed to code anything? If
    System.ComponentModel.Component does not have to be implemented in every
    class, then why does VB.NET implement it in the default class it creates?

    Thanks.





  2. #2
    David Bayley Guest

    Re: why do I need System.ComponentModel.Component?


    > If every class must inherit System.ComponentModel.Component and each
    > class is limited to just one base class, how am I supposed to code
    > anything? If System.ComponentModel.Component does not have to be
    > implemented in every class, then why does VB.NET implement it in the
    > default class it creates?


    It implements it by default, because when creating a class library project,
    it is assumed you want to have at least one Component as the root of that
    library.

    A Component is "designable", just like a UserControl, and provides the base
    implementation for integrating with IDEs. IOW, you can add Components to
    toolboxes, drag-&-drop them onto designer palettes, and set properties using
    the property sheet.

    However, deriving from Component is by no means required. You can simply
    delete the "Inherits Component" bit, and derive from Object or anything else
    if you want. Alternatively just create a blank project (can't remember if
    one exists on the new project dialog) and add standard classes to it, or
    just delete the default Component class that is created.

    Essentially there are only 2 types of project: An executable (exe) which
    contains a Main method to start it off, and a library (dll) which doesn't
    contain a Main method.

    --
    David.


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