BindingSource.ResetBindings Method

Causes a control bound to the BindingSource to reread all the items in the list and refresh their displayed values.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public void ResetBindings(
	bool metadataChanged
)

Parameters

metadataChanged
Type: System.Boolean

true if the data schema has changed; false if only values have changed.

The ResetBindings method informs all controls bound to the BindingSource to refresh their values. The method does this by raising the ListChanged event at least once; the metaDataChanged parameter indicates the nature of the underlying change.

Regardless of the value of metaDataChanged, a ListChanged event is raised with ListChangedEventArgs.ListChangedType set to ListChangedType.Reset. As a consequence, calling ResetBindings with a parameter of true will raise two ListChanged events.

ResetBindings is automatically called whenever another member makes major changes to the data-binding, such as setting the DataSource or DataMember properties. However, the programmer can also call this method explicitly.

The following code example uses a BindingSource component to bind an array list, which does not provide change notification. An item is removed from the list, and the bound controls are notified of the change by calling the ResetBindings method. This code example is part of a larger example provided in How to: Reflect Data Source Updates in a Windows Forms Control with the BindingSource.

private void button1_Click(object sender, EventArgs e)
{
    // If items remain in the list, remove the first item.  
    if (states.Count > 0)
    {
        states.RemoveAt(0);

        // Call ResetBindings to update the textboxes.
        bindingSource1.ResetBindings(false);
    }
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft