C#Winforms NumericUpDown Binding

时间:2017-10-05 14:09:44

标签: c# winforms binding argumentexception

绑定属性值时抛出异常:

  

System.Windows.Forms.dll中出现“System.ArgumentException”类型的异常,但未在用户代码中处理

     

有关更多信息:对于复合DataBinding,IList或   IListSource可以作为数据源。

表格

public partial class MainForm : Form, IPresenter<MainPresenter>
{
        private MainPresenter _presenter;
        public MainForm()
        {
            InitializeComponent();
            _presenter = new MainPresenter() { Current = this };
            numericUpDown1.DataBindings.Add(new Binding("Value", _presenter, nameof(_presenter.YearOfIssue), false, DataSourceUpdateMode.OnPropertyChanged));

        }
}

Presetner

public class MainPresenter : PresenterBase, IView<MainForm>
{
        private decimal _yearOfIssue;
        private MainForm _form;

        public decimal YearOfIssue
        {
            get
            {
                return _yearOfIssue;
            }
            set
            {
                _yearOfIssue = value;
                OnChanged("YearOfIssue");
            }
        }
}

问题

如何在Control NumericUpDown中正确绑定属性“Value”?

0 个答案:

没有答案