TypeDescriptor.GetComponentName 方法

定义

返回指定的组件的名称。

重载

GetComponentName(Object)

使用默认类型描述符返回指定组件的名称。

GetComponentName(Object, Boolean)

使用自定义类型描述符返回指定组件的名称。

GetComponentName(Object)

Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs

使用默认类型描述符返回指定组件的名称。

public static string GetComponentName (object component);
public static string? GetComponentName (object component);

参数

component
Object

需要其类名的 Object

返回

包含指定组件的名称的 String,如果没有任何组件名,则为 null

例外

componentnull

component 是一个跨进程进行远程处理的对象。

注解

通常,此方法返回组件站点的名称(如果存在)。 例如,按钮的类名称为“System.Windows”。Forms。按钮”。

此方法等效于具有第二个参数的false重载GetComponentName(Object, Boolean)方法。

此方法在设计时用于检索组件实例的名称。

另请参阅

适用于

GetComponentName(Object, Boolean)

Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs
Source:
TypeDescriptor.cs

使用自定义类型描述符返回指定组件的名称。

public static string GetComponentName (object component, bool noCustomTypeDesc);
public static string? GetComponentName (object component, bool noCustomTypeDesc);

参数

component
Object

需要其类名的 Object

noCustomTypeDesc
Boolean

若不考虑自定义类型描述信息时,为 true;否则为 false

返回

为指定组件的类名,或者,如果不存在任何组件名,则为 null

例外

componentnull

component 是一个跨进程进行远程处理的对象。

注解

此方法在设计时用于检索组件实例的名称。 通常,此方法返回组件站点的名称(如果存在)。 例如,按钮的类名称为“System.Windows”。Forms。按钮”。 如果组件实现 ICustomTypeDescriptor 接口,则可以返回备用名称。

另请参阅

适用于