CurrencyManager.Refresh 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
强制重新填充数据绑定列表。
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) 。