BindingSource.ResetItem(Int32) Yöntem

Tanım

Belirtilen dizinde BindingSource öğeyi yeniden okumak ve görüntülenen değerini yenilemek için öğesine bağlı bir denetime neden olur.

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

Parametreler

itemIndex
Int32

Değişen öğenin sıfır tabanlı dizini.

Örnekler

Aşağıdaki kod örneği, listeyi denetime BindingSource bağlamak için bir DataGridView bileşen kullanır. Liste değişiklik bildirimleri oluşturmaz, bu nedenle ResetItem üzerindeki BindingSource yöntemi olayı yükseltmek ListChanged için kullanılır. Bu kod örneği, Nasıl yapılır: BindingSource ResetItem Yöntemini Kullanarak Değişiklik Bildirimleri Oluşturma bölümünde sağlanan daha büyük bir örneğin parçasıdır.

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

Açıklamalar

yöntemi, ResetItem belirtilen öğeye Position bağlı tüm denetimlerin değerlerini yenilemesini bildirir. yöntemi bunu, olarak ayarlanmış ListChangedType.ItemChangedolayı ListChangedEventArgs.ListChangedType oluşturarak ListChanged yapar.

ResetItem , tek bir öğenin değerinde her değişiklik yapıldığında otomatik olarak çağrılır. Ancak programcı bu yöntemi açıkça da çağırabilir.

Şunlara uygulanır

Ayrıca bkz.