CurrencyManager.Refresh Méthode

Définition

Force un nouveau remplissage de la liste liée aux données.

public:
 void Refresh();
public void Refresh ();
member this.Refresh : unit -> unit
Public Sub Refresh ()

Exemples

L’exemple de code suivant crée un tableau et le lie à un TextBox contrôle, puis modifie une valeur. La Refresh méthode peut être appelée pour mettre à jour la valeur affichée par le TextBox contrôle.

void DemonstrateRefresh()
{
   
   // Create an array with ten elements and bind to a TextBox.
   array<String^>^myArray = gcnew array<String^>(10);
   for ( int i = 0; i < 10; i++ )
   {
      myArray[ i ] = String::Format( "item {0}", i );

   }
   textBox1->DataBindings->Add( "Text", myArray, "" );
   
   // Change one value.
   myArray[ 0 ] = "New value";
   
   // Uncomment the next line to refresh the CurrencyManager.
   // RefreshGrid(myArray);
}

void RefreshGrid( Object^ dataSource )
{
   CurrencyManager^ myCurrencyManager = dynamic_cast<CurrencyManager^>(this->BindingContext[ dataSource ]);
   myCurrencyManager->Refresh();
}
private void DemonstrateRefresh(){
    // Create an array with ten elements and bind to a TextBox.
    string[] myArray= new string[10];
    for(int i = 0; i <10; i++){
       myArray[i] = "item " + i;
    }
    textBox1.DataBindings.Add ("Text",myArray,"");
    // Change one value.
    myArray[0]= "New value";

    // Uncomment the next line to refresh the CurrencyManager.
    // RefreshGrid(myArray);
 }
 private void RefreshGrid(object dataSource){
    CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[dataSource];
    myCurrencyManager.Refresh();
 }
Private Sub DemonstrateRefresh()
    ' Create an array with ten elements and bind to a TextBox.
    Dim myArray(9) As String
    Dim i As Integer
    For i = 0 To 9
        myArray(i) = "item " & i
    Next i
    textBox1.DataBindings.Add("Text", myArray, "")
    ' Change one value.
    myArray(0) = "New value"

    ' Uncomment the next line to refresh the CurrencyManager.
    ' RefreshGrid(myArray);

End Sub

Private Sub RefreshGrid(dataSource As Object)
    Dim myCurrencyManager As CurrencyManager = CType(Me.BindingContext(dataSource), CurrencyManager)
    myCurrencyManager.Refresh()
End Sub

Remarques

Utilisez la Refresh méthode lorsque la source de données ne prend pas en charge la notification lorsqu’elle est modifiée (par exemple, s’il s’agit d’un Array).

S’applique à

Voir aussi