Willy,
>Thanks a lot for your prompt answer.
>
>Here you have the stack trace that I get if I don't hydrate the object before calling the NewRow() method.
>
>. . . . . .
>
>
>at OakLeaf.MM.Main.Business.mmBusinessObject.GetRowCount(String tableName)
> at OakLeaf.MM.Main.Windows.Forms.mmBindingStrategySimple.BindData(ImmBindingSimple mmControl, DataSet ds, String tableName, String fieldName, mmBusinessObject bizObj)
> at OakLeaf.MM.Main.Windows.Forms.mmBindingStrategySimple.BindData(ImmBindingSimple mmControl, mmBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
> at OakLeaf.MM.Main.Windows.Forms.mmBindingStrategySimple.BindData(ImmBindingSimple mmControl, mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
> at OakLeaf.MM.Main.Windows.Forms.mmTextBox.OnBindData(mmBaseBusinessObject bindingSource, mmBusinessStateChangeEventArgs e)
> at OakLeaf.MM.Main.Windows.Forms.mmUIHelper.StateChangeHandlerSimple(Control control, mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
> at OakLeaf.MM.Main.Windows.Forms.mmTextBox.StateChangeHandler(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
> at OakLeaf.MM.Main.Business.mmBusinessStateChangeDelegate.Invoke(mmBaseBusinessObject bizObj, mmBusinessStateChangeEventArgs e)
> at OakLeaf.MM.Main.Business.mmBusinessObject.OnStateChange(mmBusinessState bizState, String tableName, Object primaryKeyValue, Object[] primaryKeyValues)
> at OakLeaf.MM.Main.Business.mmBusinessObject.CallStateChange(mmBusinessState bizState, String tableName, DataRow dr)
> at OakLeaf.MM.Main.Business.mmBusinessObject.CallStateChange(mmBusinessState bizState, String tableName)
> at OakLeaf.MM.Main.Business.mmBusinessObject.SetCurrentDataSet(DataSet ds, String tableName, Boolean setRequiredFields, Boolean raiseEvents)
> at OakLeaf.MM.Main.Business.mmBusinessObjectGeneric`1.SetCurrentDataSet(DataSet ds, String tableName, Boolean setRequiredFields, Boolean raiseEvents)
> at OakLeaf.MM.Main.Business.mmBusinessObject.SetCurrentDataSet(DataSet ds, String tableName, Boolean setRequiredFields)
> at OakLeaf.MM.Main.Business.mmBusinessObject.SetCurrentDataSet(DataSet ds, String tableName)
> at OakLeaf.MM.Main.Business.mmBusinessObject.NewRow(DataSet ds, String tableName, Object defaultValues)
> at OakLeaf.MM.Main.Business.mmBusinessObject.NewRow(DataSet ds, String tableName)
> at OakLeaf.MM.Main.Business.mmBusinessObject.NewRow(String tableName)
> at OakLeaf.MM.Main.Business.mmBusinessObject.NewRow()
> at Target.ProTrack.WinApp.VehicleEditForm..ctor(Int32 VehicleID) in D:\Data\DevProjects08\ProTrack\ProTrackWinApp\VehicleEditForm.cs:line 38
> at Target.ProTrack.WinApp.VehiclesListForm.toolStripButtonNew_Click(Object sender, EventArgs e) in D:\Data\DevProjects08\ProTrack\ProTrackWinApp\VehiclesListForm.cs:line 55
> at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
> at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
> at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
> at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
> at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
> at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
> at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
> at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
> at System.Windows.Forms.Control.WndProc(Message& m)
> at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
> at System.Windows.Forms.ToolStrip.WndProc(Message& m)
> at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
> at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
> at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
> at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
> at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
> at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
> at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
> at System.Windows.Forms.Application.Run(Form mainForm)
> at Target.ProTrack.WinApp.AppMainEntry.Main() in D:\Data\DevProjects08\ProTrack\ProTrackWinApp\Main.cs:line 43
The reason you're getting this error is because the user interface controls are bound to the business object but there is no underlying data in the business object. If you put the call to New() before the call to InitializeComponent() I believe the error will go away.
Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com