BindingSource.ResetItem(Int32) Metódus

Definíció

Az elemnek a BindingSource megadott indexben való újraolvasásához és a megjelenített érték frissítéséhez kapcsolódó vezérlőt okoz.

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

Paraméterek

itemIndex
Int32

A módosított elem nulla alapú indexe.

Példák

Az alábbi példakód egy összetevőt használ egy BindingSource lista vezérlőelemhez való kötéséhez DataGridView . A lista nem hoz elő változásértesítéseket, ezért a ResetItemBindingSource rajta lévő metódus az esemény emelésére ListChanged szolgál. Ez a példakód egy nagyobb példa része, amely a Hogyan: Változásértesítések kérése a BindingSource ResetItem metódus használatával című témakörben található.

// 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

Megjegyzések

A ResetItem metódus értesíti az elemhez kötött összes vezérlőt a megadott Position értékük frissítéséhez. A metódus ezt úgy teszi, hogy az eseményt a ListChanged következő értékre ListChangedEventArgs.ListChangedTypeListChangedType.ItemChangedemeli: .

ResetItem a rendszer automatikusan meghívja az egyes elemek értékének módosításakor. A programozó azonban explicit módon is meghívhatja ezt a módszert.

A következőre érvényes:

Lásd még