Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
What's the need for the Component class? It only has a handful of properties and methods. Why couldn't you just have the Control class? Can you give me an example of the use of a Component which is not a Control?
Posted
I could be wrong, but I'd guess its for things like the Timer class. I believe this is a component, but it has no actually physical representation in a project like controls do.
Anybody looking for a graduate programmer (Midlands, England)?
Posted
I could be wrong' date=' but I'd guess its for things like the Timer class. I believe this is a component, but it has no actually physical representation in a project like controls do.[/quote']

 

Yes, you're right. It inherits from Component, not Control. Common dialogs are the same. I guess if you objects that have events and you want to make it easy to add them to a form, it's good to put those objects in the toolbox. Otherwise the user has to declare them With Events. So I suppose it's easier to have both those objects and controls inherit from a common base class for the purpose of programming the toolbox.

  • Leaders
Posted

Compared to a control, a component is very simple. The biggest difference is that a component does not go on the form physically. It is shown in the component tray in the designer but at run-time it is simply held in a variable. Not having its own window and all of the variables and message processing that are necessary for a control is a resource-saver. More importantly, making a class a component instead of a control makes your intent for the use of the class more obvious.

 

The whole idea behind the component class is that it can be used in a designer, allowing us to do more in the designer and less code writing. It has nothing to do with controls.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...