BindingSource.ResetItem(Int32) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Způsobí, že ovládací prvek vázaný na BindingSource znovu načte položku v zadaném indexu a aktualizuje zobrazenou hodnotu.
public:
void ResetItem(int itemIndex);
public void ResetItem(int itemIndex);
member this.ResetItem : int -> unit
Public Sub ResetItem (itemIndex As Integer)
Parametry
- itemIndex
- Int32
Index položky, která se změnila na základě nuly.
Příklady
Následující příklad kódu používá komponentu BindingSource k vytvoření vazby seznamu k ovládacímu DataGridView prvku. Seznam nevyvolá oznámení o změnách, takže ResetItem metoda na této BindingSource události se použije k vyvolání ListChanged události. Tento příklad kódu je součástí rozsáhlejšího příkladu uvedeného v části Postupy: Vyvolání oznámení o změnách pomocí BindingSource ResetItem – metoda.
// 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
Poznámky
Metoda ResetItem upozorní všechny ovládací prvky vázané na položku na zadaném místě Position , aby aktualizovaly své hodnoty. Metoda to provede vyvoláním ListChanged události s ListChangedEventArgs.ListChangedType nastavenou na ListChangedType.ItemChanged.
ResetItem je automaticky volána při každé změně hodnoty jednotlivé položky. Programátor však může tuto metodu také explicitně volat.