Component.Site Property


取得或設定 ComponentISiteGets or sets the ISite of the Component.

 virtual property System::ComponentModel::ISite ^ Site { System::ComponentModel::ISite ^ get(); void set(System::ComponentModel::ISite ^ value); };
public virtual System.ComponentModel.ISite Site { get; set; }
member this.Site : System.ComponentModel.ISite with get, set
Public Overridable Property Site As ISite

Property Value


ISite 關聯的 Component。如果 Component 未封裝在 IContainerComponent 沒有關聯的 ISite,或 Component 從其 IContainer 移除,則為 nullThe ISite associated with the Component, or null if the Component is not encapsulated in an IContainer, the Component does not have an ISite associated with it, or the Component is removed from its IContainer.




如果 Component 已加入 IContainer,而且 IContainerISite 指派給它,則會有 ISiteA Component will have an ISite if it has been added to an IContainer and the IContainer assigns an ISite to it. IContainer 負責將 ISite 指派給 ComponentThe IContainer is responsible for assigning the ISite to the Component. 變更元件 ISite 的值,不一定會變更指派 Component 的網站名稱。Changing the value of the component's ISite does not necessarily change the name of the site the Component is assigned to. Site 屬性只能由 IContainer設定。The Site property should be set only by an IContainer.

如果 Component 從其 IContainer中移除,則會 null 屬性值。The property value is null if the Component is removed from its IContainer. null 指派給這個屬性並不一定會從 IContainer移除 ComponentAssigning null to this property does not necessarily remove the Component from the IContainer.

Component 不一定會有名稱。A Component might or might not have a name. 如果 Component 指定了名稱,此名稱在其 IContainer內的其他 Component 物件中必須是唯一的。If a Component is given a name, the name must be unique among other Component objects within its IContainer. ISite 儲存 Component的名稱;因此,只有當 Component 有與其相關聯的 ISite 時,您才能命名。The ISite stores the name of the Component; therefore, you can only name a Component if it has an ISite associated with it.

Applies to

See also