What is the Control.Site property?

In Windows Forms applications, the controls in the library System.Windows.Forms

have a property named Site

. What are these properties in controls?

+3


source to share


2 answers


Sites associate a Component with a Container and provide communication between them, as well as allow the container to manage its components. Sites can also serve as a repository for specific container information for each component, such as the component name. For more information on components, see Programming with components .

Developer Notes

To be a site, a class must implement the ISite interface.



Link: https://msdn.microsoft.com/en-us/library/system.componentmodel.isite.aspx

0


source


The property Site

inherits from Component

and is very similar to the property Parent

for Control

.

The main difference between Parent

and Site

is that a value Parent

can only Control

or Site

can have a non-visual container assigned to it.

The base class is Component

used for those non-visual tools in the Winforms developer toolbox. For example, System.Windows.Forms.Timer

which can be dragged onto Form

. The PropertyGrid property can be used to set its properties and assign event handlers, all from the constructor without writing a line of code.



The idea behind the classes System.ComponentModel

is to provide API libraries for software to take advantage of the design-time capabilities of IDEs like Visual Studio. It satisfies RAD (Rapid Application Development) where generic or generic components will use the API. For example, expose additional information about an object at the bottom of the property grid or even create full custom editors .

If you want to dive deeper inside, you can look at Programming with Components , or if you want a quick overview, I think Class vs. Component vs. Control can be a good starting point.

0


source







All Articles