BindingSource.ResetItem(Int32) Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
öğesine bağlı bir denetimin BindingSource belirtilen dizinde öğeyi yeniden okumasına ve görüntülenen değerini yenilemesine 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 yöntemi BindingSource 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 değerlerini yenilemek için belirtilen Position öğeye bağlı tüm denetimleri bildirir. yöntemi bunu, olarak ayarlanmış ListChangedolayı ListChangedEventArgs.ListChangedType oluşturarak ListChangedType.ItemChanged 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.