ControlCollection.Contains(Control) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
判斷指定伺服器控制項是否在伺服器控制項的 ControlCollection 物件之中。
public:
virtual bool Contains(System::Web::UI::Control ^ c);
public virtual bool Contains (System.Web.UI.Control c);
abstract member Contains : System.Web.UI.Control -> bool
override this.Contains : System.Web.UI.Control -> bool
Public Overridable Function Contains (c As Control) As Boolean
參數
- c
- Control
要在集合中搜尋的伺服器控制項。
傳回
如果指定的伺服器控制項存在於集合中,則為 true
,否則為 false
。
範例
// Create an event handler that uses the
// ControlCollection.Contains method to verify
// the existence of a Radio3 server control in
// the ControlCollection of the myForm server control.
// When a user clicks the button associated
// with this event handler, Radio3 is removed
// from the collection.
void RemoveBtn_Click(Object sender, EventArgs e){
if (myForm.Controls.Contains(Radio3))
{
myForm.Controls.Remove(Radio3);
}
}
' Create an event handler that uses the
' ControlCollection.Contains method to verify
' the existence of a Radio3 server control in
' the ControlCollection of the myForm server control.
' When a user clicks the button associated
' with this event handler, Radio3 is removed
' from the collection.
Sub RemoveBtn_Click(sender As [Object], e As EventArgs)
If myForm.Controls.Contains(Radio3) Then
myForm.Controls.Remove(Radio3)
End If
End Sub 'RemoveBtn_Click