Export (0) Print
Expand All

BindingSource.ResetItem Method

Causes a control bound to the BindingSource to reread the item at the specified index, and refresh its displayed value.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public void ResetItem (
	int itemIndex
)
public void ResetItem (
	int itemIndex
)
public function ResetItem (
	itemIndex : int
)
Not applicable.

Parameters

itemIndex

The zero-based index of the item that has changed.

The ResetItem method notifies all controls bound to the item at the specified Position to refresh their values. The method does this by raising the ListChanged event with ListChangedEventArgs.ListChangedType set to ListChangedType.ItemChanged.

ResetItem is automatically called whenever changes are made to the value of an individual item. However, the programmer can also call this method explicitly.

The following code example uses a BindingSource component to bind a list to a DataGridView control. The list does not raise change notifications, so the ResetItem method on the BindingSource is used to raise the ListChanged event. This code example is part of a larger example provided in How to: Raise Change Notifications Using the BindingSource ResetItem Method.

// This event handler changes the value of the CompanyName
// property for the first item in the list.
void changeItemBtn_Click(object sender, EventArgs e)
{
    // Get a reference to the list from the BindingSource.
    List<DemoCustomer> customerList = 
        this.customersBindingSource.DataSource as List<DemoCustomer>;

    // Change the value of the CompanyName property for the 
    // first item in the list.
    customerList[0].CompanyName = "Tailspin Toys";

    // Call ResetItem to alert the BindingSource that the 
    // list has changed.
    this.customersBindingSource.ResetItem(0);
}

// This event handler changes the value of the CompanyName
// property for the first item in the list.
private void changeItemBtn_Click(Object sender, EventArgs e)
{
    // Get a reference to the list from the BindingSource.
    List<DemoCustomer> customerList = (List<DemoCustomer>)this.
        customersBindingSource.get_DataSource();
    // Change the value of the CompanyName property for the 
    // first item in the list.
    customerList.get_Item(0).set_CompanyName("Tailspin Toys");
    // Call ResetItem to alert the BindingSource that the 
    // list has changed.
    this.customersBindingSource.ResetItem(0);
} //changeItemBtn_Click

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft