ControlCollection.Contains(Control) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Determines whether the specified server control is in the parent server control's ControlCollection object.
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
Parameters
- c
- Control
The server control to search for in the collection.
Returns
true
if the specified server control exists in the collection; otherwise, false
.
Examples
// 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
Applies to
See also
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET