Прочетете на английски Редактиране

Споделяне чрез


TypeDescriptor.GetComponentName Method

Definition

Returns the name of the specified component.

Overloads

GetComponentName(Object)

Returns the name of the specified component using the default type descriptor.

GetComponentName(Object, Boolean)

Returns the name of the specified component using a custom type descriptor.

GetComponentName(Object)

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

Returns the name of the specified component using the default type descriptor.

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

Parameters

component
Object

The Object for which you want the class name.

Returns

A String containing the name of the specified component, or null if there is no component name.

Exceptions

component is null.

component is a cross-process remoted object.

Remarks

Typically, this method returns the name for the site of the component, if one exists. For example, the class name for a button is "System.Windows.Forms.Button".

This method is equivalent to the overloaded GetComponentName(Object, Boolean) method with a second parameter of false.

This method is used at design time to retrieve the name of an instance of a component.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetComponentName(Object, Boolean)

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

Returns the name of the specified component using a custom type descriptor.

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

Parameters

component
Object

The Object for which you want the class name.

noCustomTypeDesc
Boolean

true to not consider custom type description information; otherwise, false.

Returns

The name of the class for the specified component, or null if there is no component name.

Exceptions

component is null.

component is a cross-process remoted object.

Remarks

This method is used at design time to retrieve the name of an instance of a component. Typically, this method returns the name for the site of the component, if one exists. For example, the class name for a button is "System.Windows.Forms.Button". If the component implements the ICustomTypeDescriptor interface, it can return an alternate name.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1