當我離開我的數據網格的單元格時,從不會調用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