0

有没有更好的方法来连接 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;

我要做的就是启用保存和回滚按钮(并设置一个标志,以便在我离开时提醒我保存),似乎我正在做的事情非常基本,但我只是不知道答案.

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 
      }
   }
4

0 回答 0