ControlCollection.Remove(Control) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したサーバー コントロールを親サーバー コントロールの ControlCollection オブジェクトから削除します。
public:
virtual void Remove(System::Web::UI::Control ^ value);
public virtual void Remove(System.Web.UI.Control value);
abstract member Remove : System.Web.UI.Control -> unit
override this.Remove : System.Web.UI.Control -> unit
Public Overridable Sub Remove (value As Control)
パラメーター
- value
- Control
削除するサーバー コントロール。
例
次のコード例では、 Remove メソッドを使用して、 myButton サーバー コントロールから子コントロールを削除します。 最初に、コードは Contains メソッドを使用して、 myChildControl が ControlCollection オブジェクトに含まれているかどうかを判断し、含まれている場合は削除します。
// 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." ;
' 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
注釈
インデックスの場所からコントロールを削除するには、 RemoveAt メソッドを使用します。