BindingSource.ResetItem(Int32) 메서드

정의

BindingSource에 바인딩된 컨트롤에서 지정된 인덱스에 있는 항목을 다시 읽고 표시된 값을 새로 고치도록 합니다.

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

매개 변수

itemIndex
Int32

변경된 항목의 0부터 시작하는 인덱스입니다.

예제

다음 코드 예제에서는 BindingSource 구성 요소에 목록을 바인딩하는 DataGridView 제어 합니다. 목록 변경 알림을 발생 시 키 지 않습니다 하므로 ResetItem 메서드를 BindingSource 시키는 데 사용 됩니다는 ListChanged 이벤트입니다. 이 코드 예제는에서 제공 하는 더 큰 예제의 일부입니다 방법: BindingSource ResetItem 메서드를 사용 하 여 변경 알림 발생합니다.

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

설명

합니다 ResetItem 메서드는 지정 된 항목에 바인딩된 모든 컨트롤에 알립니다 Position 해당 값을 새로 고쳐야 합니다. 메서드는 생성 하 여이 ListChanged 사용 하 여 이벤트 ListChangedEventArgs.ListChangedType 로 설정 ListChangedType.ItemChanged합니다.

ResetItem 개별 항목의 값이 변경 될 때마다 자동으로 호출 됩니다. 그러나 프로그래머는이 메서드가 명시적으로 호출할 수도 있습니다.

적용 대상

추가 정보