Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. why inherit from Component?

why inherit from Component?

Scheduled Pinned Locked Moved C#
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ryanminor
    wrote on last edited by
    #1

    I am studying a TreeView implementation. The TreeView uses classes which encapsulate certain controls such as textbox, checkbox etc. Each item class inherits from Component (not Control). Generally speaking, why would you inherit from Component like this?

    L P 2 Replies Last reply
    0
    • R ryanminor

      I am studying a TreeView implementation. The TreeView uses classes which encapsulate certain controls such as textbox, checkbox etc. Each item class inherits from Component (not Control). Generally speaking, why would you inherit from Component like this?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, I would inherit from Component, not from Control, to get objects that can be inserted and configured with Visual Studio Designer, without them being Controls, i.e. actual GUI parts. Some examples are: System.IO.Ports.SerialPort System.Windows.Forms.Timer System.Timers.Timer see MSDN[^] For GUI parts I would derive specialized Controls from their typical original (e.g. a special TextBox from TextBox) and composite Controls from UserControl. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      Happy New Year to all.
      We hope 2010 soon brings us automatic PRE tags!
      Until then, please insert them manually.


      1 Reply Last reply
      0
      • R ryanminor

        I am studying a TreeView implementation. The TreeView uses classes which encapsulate certain controls such as textbox, checkbox etc. Each item class inherits from Component (not Control). Generally speaking, why would you inherit from Component like this?

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        When I'm a bad developer. Fortunately, as a good developer, I don't derive from either those; I implement appropriate interfaces instead. There are many places within .net where inheritance was used when interface implementation would be more appropriate.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups