共用方式為


CurrencyManager.Refresh 方法

定義

強制重新填入資料繫結清單。

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

範例

下列程式碼範例會建立陣列,並將它系結至 TextBox 控制項,然後變更一個值。 Refresh您可以呼叫 方法來更新 控制項所 TextBox 顯示的值。

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

備註

Refresh例如,如果資料來源是 Array) ,則當資料來源不支援通知 (時,請使用 方法。

適用於

另請參閱