什么是C#winform中的等效UpdateSourceTrigger?

时间:2012-11-10 05:14:21

标签: c# wpf winforms data-binding binding

我有疑问。什么是C#windows应用程序中的等效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 个答案:

答案 0 :(得分:1)

Binding.DataSourceUpdateMode正是您要找的。

using System.Windows.Forms;

// ...

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

    this.nameTextBox.DataBindings.Add(binding);