CurrencyManager.Refresh Method ()

 

Forces a repopulation of the data-bound list.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public void Refresh()

Use the Refresh method when the data source does not support notification when it is changed (for example, if it is an Array).

The following code example creates an array and binds it to a TextBox control, and then changes one value. The Refresh method can be called to update the value displayed by the TextBox control.

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();
 }

.NET Framework
Available since 1.1
Return to top
Show: