System.IndexOutOfRangeException was unhandled by user code Message="Index -1 does not have a value." Source="System.Windows.Forms" StackTrace: at System.Windows.Forms.CurrencyManager.get_Item(Int32 index) at System.Windows.Forms.CurrencyManager.get_Current() at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.GetCurrentRow(DataSet ds, String tableName) at OakLeaf.MM.Main.Windows.Forms.mmBusinessForm.Cancel(mmBusinessObject bizObj, String tableName) at CMS.Main.Windows.Forms.cmsBusinessForm.Cancel(mmBusinessObject bizObj, String tableName) in D:\cms\AA3\CMSWindowsForms\cmsBusinessForm.cs:line 193 at OakLeaf.MM.Main.Windows.Forms.mmButtonHelper.CancelHandler(Object button, String bindingSource, String bindingSourceMember, mmBaseBusinessObject& bizObj) at OakLeaf.MM.Main.Windows.Forms.mmButtonCancel.mmButtonCancel_Click(Object sender, EventArgs e) at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)It seems to error in the following code trying to find the binding context.
/// <summary> /// Returns the current row of the specified DataSet and table /// </summary> /// <param name="ds">DataSet</param> /// <param name="tableName">Table Name</param> /// <returns>DataRowView of the current row</returns> public virtual DataRowView GetCurrentRow(DataSet ds, string tableName) { return (DataRowView)this.BindingContext[ds, tableName].Current; }Any help would be appreciated.