CurrencyManager.Refresh Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Forces a repopulation of the data-bound list.
public:
void Refresh();
public void Refresh ();
member this.Refresh : unit -> unit
Public Sub Refresh ()
Examples
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.
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
Remarks
Use the Refresh method when the data source does not support notification when it is changed (for example, if it is an Array).
Applies to
See also
Met ons samenwerken op GitHub
De bron voor deze inhoud vindt u op GitHub, waar u ook problemen en pull-aanvragen kunt maken en controleren. Bekijk onze gids voor inzenders voor meer informatie.