有没有更好的方法来挂钩PropertyChanged?
List<VisitorHost> _hosts = context.VisitorHosts.Where(a => a.Clients_Id == client.Id).Where(a => a.Inactive == false).ToList();
foreach (VisitorHost vh in _hosts)
{
vh.PropertyChanged += new PropertyChangedEventHandler (visitorhost_PropertyChanged);
}
此_hosts附加到BindingSource:
visitorhostBindingSource.DataSource = _hosts;
BindingSource附加到DataGridView:
visitorHostsDataGridView.DataSource = visitorhostBindingSource;
我想要做的就是启用Save和RollBack按钮(并设置一个flg,这样如果我离开就会提醒我保存),看起来我正在做的是非常基本的,但我只是不这样做知道答案。
void visitorhost_PropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (!flgLoading) // Don't update if initialization
{
SetModified (); // turn on buttons and update Flag for parent container
}
}