This documentation is archived and is not being maintained.

ControlBindingsCollection.Clear Method

Clears the collection of any bindings.

[Visual Basic]
Public Shadows Sub Clear()
[C#]
public new void Clear();
[C++]
public: void Clear();
[JScript]
public hide function Clear();

Remarks

The CollectionChanged event occurs when the collection is cleared.

Example

[Visual Basic, C#, C++] The following example uses the Clear method to clear the ControlBindingsCollection for each control on a form.

[Visual Basic] 
Private Sub ClearAllBindings()
    Dim c As Control
    For Each c In  groupBox1.Controls
        c.DataBindings.Clear()
    Next c
End Sub

[C#] 
private void ClearAllBindings()
{
   foreach(Control c in groupBox1.Controls)
   c.DataBindings.Clear();
}

[C++] 
private:
void ClearAllBindings()
{
   System::Collections::IEnumerator* myEnum = groupBox1->Controls->GetEnumerator();
   while (myEnum->MoveNext())
   {
      Control* c = __try_cast<Control*>(myEnum->Current);
      c->DataBindings->Clear();
   }
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

ControlBindingsCollection Class | ControlBindingsCollection Members | System.Windows.Forms Namespace

Show: