TypeDescriptor.GetComponentName 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳指定元件名稱。
多載
| 名稱 | Description |
|---|---|
| GetComponentName(Object) |
使用預設類型描述元傳回指定元件的名稱。 |
| GetComponentName(Object, Boolean) |
使用自定義型別描述元傳回指定元件的名稱。 |
GetComponentName(Object)
使用預設類型描述元傳回指定元件的名稱。
public:
static System::String ^ GetComponentName(System::Object ^ component);
public static string GetComponentName(object component);
static member GetComponentName : obj -> string
Public Shared Function GetComponentName (component As Object) As String
參數
傳回
A String 包含指定元件名稱,或 null 若無元件名稱。
例外狀況
component 是 null。
component 是一個跨程序的遠端物件。
備註
通常,此方法會回傳元件所在網站名稱(若存在的話)。 例如,按鈕的類別名稱是「System.Windows。表單。按鈕」。
此方法等同於帶有第二個參數 的false超載GetComponentName(Object, Boolean)方法。
此方法在設計時用於擷取元件實例名稱。
另請參閱
- GetComponentName()
- GetClassName
- GetFullComponentName(Object)
- CreateInstance(IServiceProvider, Type, Type[], Object[])
- GetReflectionType
適用於
GetComponentName(Object, Boolean)
使用自定義型別描述元傳回指定元件的名稱。
public:
static System::String ^ GetComponentName(System::Object ^ component, bool noCustomTypeDesc);
public static string GetComponentName(object component, bool noCustomTypeDesc);
static member GetComponentName : obj * bool -> string
Public Shared Function GetComponentName (component As Object, noCustomTypeDesc As Boolean) As String
參數
- noCustomTypeDesc
- Boolean
true不考慮自訂型別描述資訊;否則,。 false
傳回
指定元件的類別名稱,或 null 若沒有元件名稱。
例外狀況
component 是 null。
component 是一個跨程序的遠端物件。
備註
此方法在設計時用於擷取元件實例名稱。 通常,此方法會回傳元件所在網站名稱(若存在的話)。 例如,按鈕的類別名稱是「System.Windows。表單。按鈕」。 如果元件實作了該 ICustomTypeDescriptor 介面,它可以回傳一個替代名稱。
另請參閱
- GetComponentName()
- ICustomTypeDescriptor
- GetClassName
- GetFullComponentName(Object)
- CreateInstance(IServiceProvider, Type, Type[], Object[])
- GetReflectionType