我有一個datagridview,我綁定到一個類。我添加到類,但datagridview不更新。C#Datagridview綁定到不更新的類
我的綁定:
ScannedChecks = new ScannedChecks();
ScannedChecks.AddCheck(DateTime.Now, "22222", "checknumdd", "routingdd", _checkData, 4);
dataGridView1.DataSource = ScannedChecks;
我繼續做了AddCheck,看它是否達到了在DataGridView並且不......這個班雖然被更新。
我的類:
namespace SSS.Ckentry
{
public class ScannedChecks : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public ScannedChecks()
{
ScannedChecksCollection = new ObservableCollection<ScannedCheck>();
}
public void AddCheck(DateTime checkDate, string accountNumber, string checkNumber, string bankRoutingNumber, string bankAccountNumber, decimal checkAmount)
{
var scc = new ScannedCheck
{
CheckDate = checkDate,
AccountNumber = accountNumber,
CheckNumber = checkNumber,
BankRoutingNumber = bankRoutingNumber,
BankAccountNumber = bankAccountNumber,
CheckAmount = checkAmount,
};
ScannedChecksCollection.Add(scc);
}
public ObservableCollection<ScannedCheck> ScannedChecksCollection { get; set; }
public class ScannedCheck
{
public DateTime CheckDate { get; set; }
public string AccountNumber { get; set; }
public string CheckNumber { get; set; }
public string BankRoutingNumber { get; set; }
public string BankAccountNumber { get; set; }
public decimal CheckAmount { get; set; }
}
}
}
誰能告訴我什麼,我做錯了什麼?
非常感謝!
同樣的,他需要在他自己的對象的屬性通知道具的變化而不是快捷獲取/套。 – SQLMason 2011-04-03 13:44:58
And ...而不是AddCheck(...)他可以只是ScannedChecks.Add(新ScannedCheck(){CheckDate = ....}); – SQLMason 2011-04-03 13:47:18