当我离开我的数据网格的单元格时,从不会调用BindingSource.AddingNew。C#BindingSource.AddingNew永远不会被调用?
DataGrid具有BindingSource的数据源,该BindingSource又具有“Customer”的“List”。
BindingSource需要创建一个新的Customer对象并将其添加到底层的ICustomerList中?
当然的接口没有构造...
,但我的客户对象有一个默认的构造函数!
那异常我得到:
System.MissingMethodException: The constcructor for the type "SAT.EnCoDe.Administration.ICustomer" was not found.
贝System.RuntimeType.CreateInstanceImpl(的BindingFlags bindingAttr,粘结剂粘结剂,对象[]指定参数时,CultureInfo的文化,对象[] activationAttributes) 贝System.SecurityUtils.SecureCreateInstance (Type type,Object [] args) bei System.ComponentModel.BindingList 1.AddNewCore() bei System.ComponentModel.BindingList
1.System.ComponentModel.IBindingList.AddNew() bei System.Windows.Forms.BindingSource.AddNew() bei System.Windows.Forms.CurrencyManager .AddNew() bei DevExpress.Data.CurrencyDataController。 OnCurrencyManagerAddNew() 贝DevExpress.Data.CurrencyDataController.AddNewRow() 贝DevExpress.XtraGrid.Views.Grid.GridView.OnActiveEditor_ValueModified(对象发件人,EventArgs的) 贝DevExpress.XtraEditors.Repository.RepositoryItem.RaiseModified(EventArgs的) 贝DevExpress.XtraEditors.BaseEdit.OnEditValueChanging(ChangingEventArgs E) 贝DevExpress.XtraEditors.TextEdit.OnMaskBox_ValueChanged(对象发件人,EventArgs的) 贝DevExpress.XtraEditors.Mask.MaskBox.RaiseEditTextChanged() 贝System.Windows.Forms.TextBoxBase .WmReflectCommand(Message & m) be DevExpress.XtraEditors.Mask.MaskBox.BaseWndProc(Message & m) be DevExpress.XtraEditors.Ma sk.MaskBox.WndProc(消息&米) 贝DevExpress.XtraEditors.TextBoxMaskBox.WndProc(消息& MSG) 贝System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息&米) 贝System.Windows.Forms的。 NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)
wpf ...好的一个,200000 LOC应用程序永远不会看到美丽的WPF光... http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource。 allownew.aspx 在那个链接我看到了AllowNew被设置为false的3个原因,在我的BindingSource属性AllowNew上被设置为false 。 我想其原因3,所以我固定它通过添加一个参数的构造函数,但 我仍然得到同样的错误,也许 因为有另一个构造函数,带一个参数为新的GUID()为客户对象? – msfanboy 2010-06-08 12:22:03
我删除了第二个Ctor,但参数仍然是我得到的异常:/ – msfanboy 2010-06-08 12:29:48
确定这里我们去: 即使使用默认Ctor BindingSource的属性窗口将AddNew属性设置为FALSE只是当我分配DataSource的类型ICustomerList。 我甚至有IBindingList实现或BindingList它实现IBindingList。 尽管所有的要求,我fullfilled它不起作用。 因此,我现在赶上BindingSource_AddNew事件并通过 添加新客户e.NewObject = new Customer(Guid.NewGuid()); 它迄今为止工作... –
msfanboy
2010-06-08 18:28:29