2014-09-04 83 views
1

我有DataGridView和數據源是列表。當我在gridview中更改該列表中的元素屬性時,它會顯示在前面。當我點擊行時,它會更改值。我正在使用BackgroundWorker更新列表。如何在同一時間更新DataGridView?DataGridView不更新當我更改數據源

+0

ObservableCollection代替List? – SAm 2014-09-04 13:45:16

+0

List <_Input> oldList; public class _Input { public string Title {get;組; } public string Item {get;組; } public double Cost {get;組; } public double FixedPrice {get;組; } public double FloorPrice {get;組; } 公共字符串Asin1 {get;組; } public bool Edited {get;組; } } – 2014-09-04 13:48:27

+1

你可以試試,System.Collections.ObjectModel.ObservableCollection <_Input> oldList而不是列表<_Input> oldList? – SAm 2014-09-04 13:53:47

回答

0

修改摘自msdn

private void RefreshGrid(object dataSource) 
{ 
    yourGridName.Invoke((Action)delegate 
    { 
     var myCurrencyManager = (CurrencyManager)yourGridName.BindingContext[dataSource]; 
     myCurrencyManager.Refresh(); 
    }); 
} 

調用此方法時,您的後臺工作更新數據源。

相關問題