Container.ValidateName(IComponent, String) 方法

定義

判斷元件名稱對這個容器而言是否唯一。Determines whether the component name is unique for this container.

protected:
 virtual void ValidateName(System::ComponentModel::IComponent ^ component, System::String ^ name);
protected virtual void ValidateName (System.ComponentModel.IComponent component, string name);
abstract member ValidateName : System.ComponentModel.IComponent * string -> unit
override this.ValidateName : System.ComponentModel.IComponent * string -> unit
Protected Overridable Sub ValidateName (component As IComponent, name As String)

參數

component
IComponent

具名元件。The named component.

name
String

要驗證的元件名稱。The component name to validate.

例外狀況

componentnullcomponent is null.

name 不是唯一。name is not unique.

備註

方法會呼叫Add component Container方法, 以判斷要加入的名稱是否對這個而言是唯一的。 ValidateNameThe ValidateName method is called by the Add method to determine if the name of the component being added is unique for this Container. 如果參數namenull是, 而且不ArgumentException是唯一的, 則會擲回。If the name parameter is not null and is not unique, an ArgumentException is thrown.

適用於

另請參閱