why inherit from Component?
-
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?
-
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?
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.
-
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?
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.