次の方法で共有


ControlCollection.Remove メソッド

親サーバー コントロールの ControlCollection オブジェクトから、指定したサーバー コントロールを削除します。

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Public Overridable Sub Remove ( _
    value As Control _
)
'使用
Dim instance As ControlCollection
Dim value As Control

instance.Remove(value)
public virtual void Remove (
    Control value
)
public:
virtual void Remove (
    Control^ value
)
public void Remove (
    Control value
)
public function Remove (
    value : Control
)
適用できません。

パラメータ

  • value
    削除されるサーバー コントロール。

解説

インデックス位置からコントロールを削除するには、RemoveAt メソッドを使用します。

使用例

Remove メソッドを使用して、myButton サーバー コントロールから子コントロールを削除するコード例を次に示します。このコードは、まず Contains メソッドを使用して ControlCollection オブジェクトに myChildControl が含まれているかどうかを確認し、含まれていればそれを削除します。

' Use the Contains method to check whether
' a child control exists, and if it does,
' use the Remove method to delete it.        
If myButton.Controls.Contains(myChildControl)
   myButton.Controls.Remove(myChildControl)
   msgRemove.Text = "You removed myLiteralControl."
Else
   msgRemove.Text="The control to remove does not exist." 
End If
// Use the Contains method to check whether
// a child control exists, and if it does,
// use the Remove method to delete it.        
if (myButton.Controls.Contains(myChildControl))
{
   myButton.Controls.Remove(myChildControl);
   msgRemove.Text = "You removed myLiteralControl.";
}
else msgRemove.Text="The control to remove does not exist." ;

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

ControlCollection クラス
ControlCollection メンバ
System.Web.UI 名前空間
RemoveAt
Control.Controls プロパティ