BindingSource.ResetBindings(Boolean) 메서드

정의

컨트롤이 목록에 BindingSource 있는 모든 항목을 다시 읽고 표시된 값을 새로 고치도록 합니다.

public:
 void ResetBindings(bool metadataChanged);
public void ResetBindings(bool metadataChanged);
member this.ResetBindings : bool -> unit
Public Sub ResetBindings (metadataChanged As Boolean)

매개 변수

metadataChanged
Boolean

데이터 스키마가 변경되었으면 이고, 값만 변경되었으면 입니다.

예제

다음 코드 예제에서는 구성 요소를 사용하여 BindingSource 변경 알림을 제공하지 않는 배열 목록을 바인딩합니다. 항목이 목록에서 제거되고 바인딩된 컨트롤은 메서드를 호출 ResetBindings 하여 변경 내용에 대한 알림을 받습니다. 이 코드 예제는 How to: Reflect Data Source Updates in a Windows Forms Control with the BindingSource 제공된 더 큰 예제의 일부입니다.

private:
   void button1_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
   {
      String^ xml = "<US><states>"
         + "<state><name>Washington</name><capital>Olympia</capital> "
         + "<flower>Coast Rhododendron</flower></state>"
         + "<state><name>Oregon</name><capital>Salem</capital>"
         + "<flower>Oregon Grape</flower></state>"
         + "<state><name>California</name><capital>Sacramento</capital>"
         + "<flower>California Poppy</flower></state>"
         + "<state><name>Nevada</name><capital>Carson City</capital>"
         + "<flower>Sagebrush</flower></state>"
         + "</states></US>";
      
      // Convert the xml string to bytes and load into a memory stream.
      array<Byte>^ xmlBytes = Encoding::UTF8->GetBytes( xml );
      MemoryStream^ stream = gcnew MemoryStream( xmlBytes,false );
      
      // Create a DataSet and load the xml into it.
      dataSet2->ReadXml( stream );
      
      // Set the data source.
      bindingSource1->DataSource = dataSet2;
      bindingSource1->ResetBindings( true );
   }
private void button1_Click(object sender, EventArgs e)
{
    // If items remain in the list, remove the first item. 
    if (states.Count > 0)
    {
        states.RemoveAt(0);

        // Call ResetBindings to update the textboxes.
        bindingSource1.ResetBindings(false);
    }
}

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
    Handles button1.Click

    ' If items remain in the list, remove the first item. 
    If states.Count > 0 Then
        states.RemoveAt(0)

        ' Call ResetBindings to update the textboxes.
        bindingSource1.ResetBindings(False)
    End If

End Sub

설명

메서드는 ResetBindings 해당 값을 새로 고치기 위해 바인딩된 모든 컨트롤을 BindingSource 알립니다. 메서드는 이벤트를 한 번 이상 발생 ListChanged 시켜 이 작업을 수행합니다. 매개 변수는 metaDataChanged 기본 변경의 특성을 나타냅니다.

metaDataChangedListChanged 에 관계없이 이벤트는 .로 설정된 상태에서 ListChangedEventArgs.ListChangedType 발생합니다ListChangedType.Reset. 결과적으로 매개 변수 ResetBindings 를 사용하여 호출 true 하면 두 개의 ListChanged 이벤트가 발생합니다.

ResetBindings는 다른 멤버가 데이터 바인딩을 크게 변경할 때마다(DataSource예: 속성 설정DataMember) 자동으로 호출됩니다. 그러나 프로그래머가 이 메서드를 명시적으로 호출할 수도 있습니다.

적용 대상

추가 정보