Component.Site 属性

获取或设置 ComponentISite

**命名空间:**System.ComponentModel
**程序集:**System(在 system.dll 中)

语法

声明
Public Overridable Property Site As ISite
用法
Dim instance As Component
Dim value As ISite

value = instance.Site

instance.Site = value
public virtual ISite Site { get; set; }
public:
virtual property ISite^ Site {
    ISite^ get ();
    void set (ISite^ value);
}
/** @property */
public ISite get_Site ()

/** @property */
public void set_Site (ISite value)
public function get Site () : ISite

public function set Site (value : ISite)

属性值

Component 关联的 ISite(如果有)。如果 Component 未封装在 IContainer 中,Component 没有与其关联的 ISite 或者 Component 已从其 IContainer 中移除,则为 空引用(在 Visual Basic 中为 Nothing)。

备注

只有当 Component 已添加到 IContainer 中并且 IContainer 为其分配了 ISite 时,它才能具有 ISiteIContainer 负责将 ISite 分配给 Component。更改组件的 ISite 的值未必会更改 Component 所分配到的站点的名称。Site 属性只能由 IContainer 来设置。

如果 Component 已从它的 IContainer 中移除,属性值则为 空引用(在 Visual Basic 中为 Nothing)。将 空引用(在 Visual Basic 中为 Nothing) 分配给此属性不一定会将 ComponentIContainer 中移除。

Component 可能具有或没有名称。如果给 Component 提供名称,该名称必须对于其 IContainer 中的其他 Component 对象是唯一的。ISite 存储 Component 的名称,因此,只有在 Component 具有关联的 ISite 时,才能为其命名。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0

请参见

参考

Component 类
Component 成员
System.ComponentModel 命名空间
IContainer
Container
ISite