BindingSource.ResetItem(Int32) BindingSource.ResetItem(Int32) BindingSource.ResetItem(Int32) BindingSource.ResetItem(Int32) Method

Définition

Entraîne la relecture d'un contrôle lié au BindingSource à l'élément au niveau de l'index spécifié et actualise sa valeur affichée.Causes a control bound to the BindingSource to reread the item at the specified index, and refresh its displayed value.

public:
 void ResetItem(int itemIndex);
public void ResetItem (int itemIndex);
member this.ResetItem : int -> unit
Public Sub ResetItem (itemIndex As Integer)

Paramètres

itemIndex
Int32 Int32 Int32 Int32

Index de base zéro de l'élément modifié.The zero-based index of the item that has changed.

Exemples

L’exemple de code suivant utilise BindingSource un composant pour lier une liste à DataGridView un contrôle.The following code example uses a BindingSource component to bind a list to a DataGridView control. La liste ne génère pas de notifications de modifications ResetItem . la méthode BindingSource sur le est donc utilisée ListChanged pour déclencher l’événement.The list does not raise change notifications, so the ResetItem method on the BindingSource is used to raise the ListChanged event. Cet exemple de code fait partie d’un exemple plus complet fourni dans How to: Déclenchez des notifications de modifications àl’aide de la méthode ResetItem BindingSource.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 =
      static_cast<List< DemoCustomer^ >^>(
        this->customersBindingSource->DataSource);
   
   // Change the value of the CompanyName property for the
   // first item in the list.
   customerList->default[ 0 ]->CompanyName = L"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.
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 Sub changeItemBtn_Click(ByVal sender As Object, ByVal e As EventArgs) _
   Handles changeItemBtn.Click

    ' Get a reference to the list from the BindingSource.
    Dim customerList As List(Of DemoCustomer) = _
    CType(Me.customersBindingSource.DataSource, List(Of 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.
    Me.customersBindingSource.ResetItem(0)

End Sub

Remarques

La ResetItem méthode notifie tous les contrôles liés à l’élément au spécifié Position pour actualiser leurs valeurs.The ResetItem method notifies all controls bound to the item at the specified Position to refresh their values. Pour ListChangedEventArgs.ListChangedType ListChanged cefaire,laméthodedéclenchel’événementListChangedType.ItemChangedavec la valeur.The method does this by raising the ListChanged event with ListChangedEventArgs.ListChangedType set to ListChangedType.ItemChanged.

ResetItemest appelé automatiquement chaque fois que des modifications sont apportées à la valeur d’un élément individuel.ResetItem is automatically called whenever changes are made to the value of an individual item. Toutefois, le programmeur peut également appeler cette méthode explicitement.However, the programmer can also call this method explicitly.

S’applique à

Voir aussi