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.

備註

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

適用於

另請參閱