2012-11-10 78 views
1

我有问题。 C#windows应用程序中的什么是等效的UpdateSourceTrigger?什么是C#winform中的等效UpdateSourceTrigger?

public static void Bind(ComboBox cmb, ComboVAlidationRule vld) 
     { 
      Binding bndControl = new Binding("DataBind"); 
      bndControl.Source = vld; 
      bndControl.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; 
      bndControl.ValidationRules.Add(vld); 
      cmb.SetBinding(ComboBox.SelectedItemProperty, bndControl); 
     } 

回答

1

Binding.DataSourceUpdateMode是你在找什么。

using System.Windows.Forms; 

// ... 

    Binding binding = new Binding("Text", this.personBindingSource, "Name"); 
    binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; 

    this.nameTextBox.DataBindings.Add(binding); 
+0

'INotifyPropertyChanged'不在Winforms中使用,对不对? – LuckyLikey

+0

@LuckyLikey它*用于WinForms,并在对象实现'INotifyPropertyChanged'时正常工作。请参阅[这里](https://msdn.microsoft.com/en-us/library/xz45s2bh.aspx) –

相关问题