Linq to sql Linq sql数据绑定到winforms组合框
我正在尝试将ComboxBox绑定到外键表。我知道on不能绑定到实际的外键SomeTableClassFK,当FK已经有值时会导致LinqSql异常。因此,我通过ComboBox的SelectedItem属性绑定到FK对象SomeTable引用。 某个原始表 SomeTableClassFK-->SomeTableClass.PK SomeTable-->SomeTableClass this.aComboBox.DataBindings.Addnew System.Windows.Forms.BindingSelectedItem,this.somePrimaryTableBindingSource,PendingReason,false; 这不管用。组合框始终将FK对象绑定到其列表中的第一项Linq to sql Linq sql数据绑定到winforms组合框,linq-to-sql,Linq To Sql,我正在尝试将ComboxBox绑定到外键表。我知道on不能绑定到实际的外键SomeTableClassFK,当FK已经有值时会导致LinqSql异常。因此,我通过ComboBox的SelectedItem属性绑定到FK对象SomeTable引用。 某个原始表 SomeTableClassFK-->SomeTableClass.PK SomeTable-->SomeTableClass this.aComboBox.DataBindings.Addnew System.Windows.Forms.
有什么想法吗?我不知道具体是在哪篇文章中,但我记得scottgui在linq系列中提出了这个问题的解决方案……也许是为了找到它:
干杯好的……问题被追溯到古怪的winform行为。显然,不能保证不会多次调用用户控件的OnLoad。因此,所涉及的两个表(见上图)是从不同的DataContext加载的。喷溅