BindingSource.ResetItem(Int32) Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Faz com que um controlo atribuído a releia BindingSource o item no índice especificado e atualize o seu valor apresentado.
public:
void ResetItem(int itemIndex);
public void ResetItem(int itemIndex);
member this.ResetItem : int -> unit
Public Sub ResetItem (itemIndex As Integer)
Parâmetros
- itemIndex
- Int32
O índice base zero do item que mudou.
Exemplos
O exemplo de código seguinte utiliza um BindingSource componente para associar uma lista a um DataGridView controlo. A lista não gera notificações de alteração, pelo que o ResetItem método BindingSource é usado para aumentar o ListChanged evento. Este exemplo de código faz parte de um exemplo mais amplo fornecido em Como: Levantar Notificações de Alterações Usando o Método ResetItem BindingSource.
// 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
Observações
O ResetItem método notifica todos os controlos vinculados ao item no especificado Position para atualizarem os seus valores. O método faz isto elevando o ListChanged evento com ListChangedEventArgs.ListChangedType definido para ListChangedType.ItemChanged.
ResetItem é chamada automaticamente sempre que são feitas alterações ao valor de um item individual. No entanto, o programador também pode chamar este método explicitamente.