这是由C#生成设计类:如何将新项目添加到与实体绑定的组合框?
//
// usepurposeComboBox
//
this.usepurposeComboBox.DataSource = this.usepurposeBindingSource;
this.usepurposeComboBox.DisplayMember = "Name";
this.usepurposeComboBox.FormattingEnabled = true;
this.usepurposeComboBox.Location = new System.Drawing.Point(277, 53);
this.usepurposeComboBox.Name = "usepurposeComboBox";
this.usepurposeComboBox.Size = new System.Drawing.Size(218, 21);
this.usepurposeComboBox.TabIndex = 4;
this.usepurposeComboBox.ValueMember = "id";
//
// usepurposeBindingSource
//
this.usepurposeBindingSource.DataSource = typeof(mydatabaseEntities.usepurpose);
然后我绑定的BindingSource的(usepurposeBindingSource)到实体:
usepurposeBindingSource.DataSource = mydatabaseEntities.usepurposes;
而且因为它被束缚我不能添加一个新行usepurposeComboBox。有没有解决方法?
它不能这样做。 System.Windows.Forms.dll中发生未处理的异常类型'System.ArgumentException' 其他信息:设置DataSource属性时无法修改Items集合。 – JatSing
为什么不添加到'this.usepurposeBindingSource'? – balexandre