winforms databinding works only on development machine

后端 未结 1 790
失恋的感觉
失恋的感觉 2021-01-21 19:50

I\'m targeting the framework 4.0 and this works fine on the development machine, I can see at startup the form with the textbox displaying binded message in it. But when I deplo

相关标签:
1条回答
  • 2021-01-21 20:14

    Breaking change in 4.0. See .Net 4.0 simple binding issue

    The work around is to use a BindingSource:

    public Form1() {
      InitializeComponent();
      _dataContext = new SimpleDataContext { Prop = new SimpleProp { Note = "hi!" } };
      BindingSource bs = new BindingSource(_dataContext, null);
      textBox1.DataBindings.Add("Text", bs, "Prop.Note");    
    }
    
    0 讨论(0)
提交回复
热议问题